|
Gurcharan, Your problem is that all of your inputs have the same id. It is invalid for any two elements of any type to share ids. If specified, it must be unique. I only ever specify them if it is necessary to access a particular DOM element, otherwise, use other methods not involving ids. If you want to group inputs, use brackets after the name to declare an array in the result. Similarly you can declare a hash of results by supplying brackets with the key for the hash inside the brackets. Form with checkboxes all using the same "name" attribute (will give an array): <form id="myform"> <input type="checkbox" name="AC[]" value="ANTIQUES & COLLECTIBLES Art" /> <input type="checkbox" name="AC[]" value="ART General" /> <input type="checkbox" name="AC[]" value="ART African" /> <input type="checkbox" name="AC[]" value="ART American General" /> </form> Use Form.serialize to gather all results in one fell swoop. Only checkboxes that were checked will be present in the result. E.g. if "ART General" and "ART African" were checked: var query = Form.serialize('myform'); //you can use this to send values back to the server (post or get parameters string) var values = query.toQueryParams(); //now values will have a nice hash like so: { AC: [ "ART General", "ART African" ] } If you use "query" as the parameters for a request, you'll also have a nice array of values on the server side accessible via (PHP example) $_POST['AC']. Lastly, to loop through all of the checked boxes, simply: values.AC.each(function(value){ //will alert the values of each checked box alert(value); }); Very clean, no? Colin Gurcharan Singh wrote: Hi! --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs -~----------~----~----~----~------~----~------~--~--- |
- [Rails-spinoffs] Re: HTML has no properties Colin Mollenhour
- [Rails-spinoffs] Re: HTML has no properties Gurcharan Singh
