October 23rd, 2008 §
example:
<input type='radio' name='test' value='1' />
<input type='radio' name='test' id='nr2' value='2' />
<input type='radio' name='test' value='3' />
$$("input[type=radio][name='test'][value='3']")[0].writeAttribute("checked", "checked");
or
$("nr2").writeAttribute("checked", "checked");
Related Blogs
October 13th, 2008 §
Prototype’s stripTags function needs a string as input. If you want to access a dom node with this function, you need to acces the innerHTML, else the input won’t match.
expl.
alert($(’mydiv’).stripTags(); -> wont work
use
alert($(’mydiv’).innerHTML.stripTags();
Related Blogs
- Related Blogs on Prototypejs
- Related Blogs on striptags()
October 9th, 2008 §
Joe Gornick wrote a Prototype extension that lets users copy data to the clipboard.
The code uses javascript in Internet Explorer and some flash for other browsers.
Check it out at Joe Gornick’s site.
October 9th, 2008 §
When using $$ in Prototype, the result is an array. You need to loop through the array to attach the observe function. Expl.
$$(’.myitems‘).each(function(item) { item.observe(’click’,function(){alert (’clicked’)});});
or
$$(’.myitems’).invoke(’observe’, ‘click’, function() {alert(’clicked’)});
October 9th, 2008 §
It’s not possible to fire the default events with Prototype 1.6. Only custom events are supported.
$(’mybutton’).observe(’click’,function(){…});
$(’mybutton’).fire(’click’); will not work
$(’myinput’).observe(’input:changed’,function(){….});
$(’myinput’).fire(’input:changed’); does work
October 9th, 2008 §
observing:
$(’mycheckbox’).observe(’click’, function(e){alert(’checked = ‘ + this.checked);});
setting throught scripting:
$(’mycheckbox’).checked = true;
$(’mycheckbox’).setAttribute(’checked’, true);
$(’mycheckbox’).setValue(”); // will un-check/null value
$(’mycheckbox’).setValue(’anything’); // will check/on value
$(’mycheckbox’).click(); // will toggle the checkbox