prototype - triggering each onchange event
I'm wondering if the following is possible, so far I got 开发者_StackOverflowit to work, however, I get three alerts since I have three text-boxes that get set at the same time. I would like to alert the new date only once.
var x = 0;
$$('.class').each(function(el) {
$(el).observe('change', function() {
d = ($('y').value + $('m').value - 1 + $('d').value);
if (x == 0) alert(d)
});
});
Only for you Mike am posting my comment as answer . You can now accpet it as answer :-)
use any flag variable. on first alert set flag. if flag set dont alert. this is just js. dont know any other prototype way
精彩评论