I need to get the text from the selected checkboxes in a form. Ifhe form is:
<form action="save" method="post" name="reunform" id="reunform" >
<div id="listad">
<ul id="litemsd">
<li class="litemd"><input type="checkbox" name="d1" />Number One</li>
<li class="litemd"><input type="checkbox" name="d2" />Numer Two</li>
<li class="litemd"><input type="checkbox" name="d3" />Numer Three</li>
</ul>
</div>
...
</form>
Using Prototype: How can I get the string “Number One\nNumberThree” should these be selected ?
To test something I tried:
$$('li.litemd').pluck('checked').each(function(s) {
alert(s.innerHtml)
});
But I’m getting “s is undefined” in firebug.
Thanks
First of all, you should be using
<label>tags on that checkbox text. This is an accessibility concern. Using labels has the added benefit of being able to click the label text to check the box, which is something that many users (myself included) have grown accustomed to…As an additional benefit, this makes your code a lot easier…