2008年9月23日星期二

Prototype JS Event.observe



Event.observe(window, 'load', function()
{
Event.observe( 'searchBt', 'click', function(e)
{
ajaxListReceiver('{$clientId}');
getWinnerCount(0);
Event.stop(e);
});
});




var phrase = "This is SPAARRTTAAAA!";

$('somelink').observe('click', sayIt.bindAsEventListener(this, phrase));

function sayIt(event, phrase) {
console.log(phrase);
}

phrase = "Red sauce on PAASTAAAA!";





var obj = { name: 'A nice demo' };

function handler(e) {
var tag = Event.element(e).tagName.toLowerCase();
var data = $A(arguments);
data.shift();
alert(this.name + '\nClick on a ' + tag + '\nOther args: ' + data.join(', '));
}

Event.observe(document.body, 'click', handler.bindAsEventListener(obj, 1, 2, 3));
// Now any click on the page displays obj.name, the lower-cased tag name
// of the clicked element, and "1, 2, 3".




/*
* add click event
*
*/

// Attaching events
for (var i = items.length; i--; ) {
Event.observe(items[i], 'click', e_onclick, false);
}
// Detaching events
for (var i = items.length; i--; ) {
Event.stopObserving(items[i], 'click', e_onclick, false);
}



/*
* add click event with "return false"
*
*/
in html file:

Event.observe(window, 'load', function() {
Event.observe('button2', 'click', onchecktime);
});

if js file:

var onchecktime = function(event){
var element = Event.element(event);

alert(Event.pointerX(event));
Event.stop(event); // avoid page reloading
};

2008年9月22日星期一

Prototype JS Event.observe

CODE:
/*
*you'd want this line of code to run once the form exists in the DOM; but putting *inline scripts in the document is pretty obtrusive, so instead we'll go for a simple *approach that waits till the page is fully loaded:
*/
Event.observe(window, 'load', function() {
Event.observe('percent', 'change', selectProPercent);
}

in main.js:
var selectProPercent = function()
{
......
}

2008年9月19日星期五

mysql_real_escape_string(PHP) SQL中的特殊字符查询

Problem:

TABLE COL => "cb_spielhalle" with context "RT-Betzingen (Carl-Zeiss-Str.)|*|RT-Betzingen (Eisenbahnstr.)|*|Mössingen|*|Tübingen|*|Li.-Unterhausen"

sql有效查询 带"Mössingen"的数据:
SELECT * FROM jos_comprofiler WHERE cb_handy != '' AND (cb_spielhalle LIKE '%Mössingen%' ) AND ( cb_infoserhaltenper = 'SMS und E-Mail' OR cb_infoserhaltenper = 'nur SMS' ) AND cb_anrede LIKE '%Frau%'

PHP有效查询 带"Mössingen"的数据:
SELECT * FROM jos_comprofiler WHERE cb_handy != '' AND (cb_spielhalle LIKE '%Mössingen%' ) AND ( cb_infoserhaltenper = 'SMS und E-Mail' OR cb_infoserhaltenper = 'nur SMS' ) AND cb_anrede LIKE '%Frau%'

其中 AND (cb_spielhalle LIKE '%Mössingen%' ) 使用了mysql_real_escape_string();
$q .= $dataDbtablecol2." LIKE '%".mysql_real_escape_string($spielhalle)."%' OR ";