<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Gurcharan,<br>
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.<br>
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.<br>
<br>
Form with checkboxes all using the same "name" attribute (will give an
array):<br>
<form id="myform"><br>
<input type="checkbox"
name="AC[]" value="ANTIQUES &
COLLECTIBLES Art" /><br>
<input type="checkbox"
name="AC[]" value="ART General" /><br>
<input type="checkbox"
name="AC[]" value="ART African" /><br>
<input type="checkbox"
name="AC[]" value="ART American General"
/><br>
</form><br>
<br>
Use Form.serialize to gather all results in one fell swoop. Only
checkboxes
that were checked will be present in the result.<br>
E.g. if "ART General" and "ART African" were
checked:<br>
<br>
var query = Form.serialize(''myform''); //you can use this to
send values
back to the server (post or get parameters string)<br>
var values = query.toQueryParams(); //now values will have a nice hash
like so:<br>
{<br>
AC: [<br>
"ART
General",<br>
"ART
African"<br>
]<br>
}<br>
<br>
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''].<br>
<br>
Lastly, to loop through all of the checked boxes, simply:<br>
<br>
values.AC.each(function(value){ //will alert the values of each checked
box<br>
alert(value);<br>
});<br>
<br>
Very clean, no?<br>
<br>
Colin<br>
<br>
Gurcharan Singh wrote:
<blockquote
cite="mid7072f9a00610100532q34936c9dg1b6c19695761366a-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org"
type="cite">Hi!<br>
<br>
Thanxs for your response. I tried as suggested but still it''s not
working. My HTML sample code is -<br>
<br>
<br>
<span style="color: rgb(51, 102, 255);"><script
src="../../includes/ajax/prototype.js"></script>
</span><br style="color: rgb(51, 102, 255);">
<span style="color: rgb(51, 102,
255);"><script></span><br
style="color: rgb(51, 102, 255);">
<br style="color: rgb(51, 102, 255);">
<span style="color: rgb(51, 102, 255);">function
update()</span><br
style="color: rgb(51, 102, 255);">
<span style="color: rgb(51, 102, 255);">{</span><br
style="color: rgb(51, 102, 255);">
<span style="color: rgb(51, 102,
255);">
</span><br
style="color: rgb(51, 102, 255);">
<span style="color: rgb(51, 102,
255);"> </span><br
style="color: rgb(51, 102, 255);">
<span style="color: rgb(51, 102,
255);">
formElements
Form.getInputs(''searchForm'',''checkbox'');</span><br
style="color: rgb(51, 102, 255);">
<span style="color: rgb(51, 102,
255);">
</span><br
style="color: rgb(51, 102, 255);">
<span style="color: rgb(51, 102,
255);"> var
len formElements.length;</span><br style="color: rgb(51, 102,
255);">
<span style="color: rgb(51, 102,
255);">
</span><br
style="color: rgb(51, 102, 255);">
<span style="color: rgb(51, 102,
255);"> </span><br
style="color: rgb(51, 102, 255);">
<span style="color: rgb(51, 102,
255);"> for( i=0 ; i< len ;
i++)</span><br style="color: rgb(51, 102, 255);">
<span style="color: rgb(51, 102,
255);">
{
</span><br
style="color: rgb(51, 102, 255);">
<span style="color: rgb(51, 102,
255);">
if(document.searchForm.elements[i].checked)</span><br
style="color: rgb(51, 102, 255);">
<span style="color: rgb(51, 102,
255);">
{
</span><br
style="color: rgb(51, 102, 255);">
<span style="color: rgb(51, 102,
255);">
</span><br
style="color: rgb(51, 102, 255);">
<span style="color: rgb(51, 102,
255);">
window.opener.document.signup.subject_1.value =
$F(formElements[i]);</span><br
style="color: rgb(51, 102, 255);">
<span style="color: rgb(51, 102,
255);">
</span><br
style="color: rgb(51, 102, 255);">
<span style="color: rgb(51, 102,
255);">
window.close();</span><br style="color: rgb(51, 102,
255);">
<span style="color: rgb(51, 102,
255);">
}</span><br
style="color: rgb(51, 102, 255);">
<span style="color: rgb(51, 102,
255);"> }</span><br
style="color: rgb(51, 102, 255);">
<span style="color: rgb(51, 102,
255);"> </span><br
style="color: rgb(51, 102, 255);">
<span style="color: rgb(51, 102, 255);">}</span><br
style="color: rgb(51, 102, 255);">
<span style="color: rgb(51, 102,
255);"></script></span><br>
<span style="color: rgb(153, 0,
0);"></head></span><br
style="color: rgb(153, 0, 0);">
<span style="color: rgb(153, 0,
0);"><body><br>
<br>
<span style="color: rgb(51, 0, 51);"><!-- Form for the
display of
search text bar !--></span><br style="color: rgb(153, 0,
0);">
</span><span style="color: rgb(51, 0,
153);"><form name="search"
method="post" action="basicSearchResult1.php
?formField=subject_1"></span><br style="color: rgb(51,
0, 153);">
<span style="color: rgb(51, 0,
153);">
<center><b>Search
Criteria:&nbsp;</b><input
type="text" name="searchValue">
</span><br style="color: rgb(51, 0, 153);">
<span style="color: rgb(51, 0,
153);"> &nbsp;<input
type="submit" value="Search"
name="searchBisac"><br /></span><br
style="color: rgb(51, 0, 153);">
<span style="color: rgb(51, 0,
153);">
</center></span><br
style="color: rgb(51, 0, 153);">
<span style="color: rgb(51, 0,
153);">
<fieldset><legend>Note</legend></span><br
style="color: rgb(51, 0, 153);">
<br style="color: rgb(51, 0, 153);">
<span style="color: rgb(51, 0,
153);"> Search on category name
e.g. art, fiction, science etc.<br /></span><br
style="color: rgb(51, 0, 153);">
<span style="color: rgb(51, 0,
153);"> Search leads to listing of
BISAC codes, when clicked shall be stored in the category of your
choice. </span><br style="color: rgb(51, 0, 153);">
<span style="color: rgb(51, 0,
153);">
</fieldset></span><br
style="color: rgb(51, 0, 153);">
<span style="color: rgb(51, 0,
153);"> </span><br
style="color: rgb(51, 0, 153);">
<span style="color: rgb(51, 0,
153);"> </span><br
style="color: rgb(51, 0, 153);">
<span style="color: rgb(51, 0, 153);"></form>
</span><br style="color: rgb(153, 0, 0);">
<br style="color: rgb(153, 0, 0);">
<!-- Form created from the search result !--><br>
<br style="color: rgb(153, 0, 0);">
<span style="color: rgb(153, 0, 0);"><form
id="searchForm">
</span><br style="color: rgb(153, 0, 0);">
<span style="color: rgb(153, 0, 0);"><br
/><input
type="checkbox" name="AC" id="AC"
value="ANTIQUES & COLLECTIBLES
Art " <span style="font-weight:
bold;">
onClick="update();</span>"></span><br
style="color: rgb(153, 0, 0);">
<span style="color: rgb(153, 0, 0);">ANT002000 ANTIQUES
&
COLLECTIBLES Art</span><br style="color: rgb(153, 0, 0);">
<br style="color: rgb(153, 0, 0);">
<span style="color: rgb(153, 0, 0);"><br
/><input
type="checkbox" name="AC" id="AC" value="ART
General " <span
style="font-weight:
bold;">onClick="update();</span>">
</span><br style="color: rgb(153, 0, 0);">
<span style="color: rgb(153, 0, 0);">ART000000 ART
General</span><br
style="color: rgb(153, 0, 0);">
<br style="color: rgb(153, 0, 0);">
<span style="color: rgb(153, 0, 0);"><br
/><input
type="checkbox" name="AC" id="AC" value="ART
African " <span
style="font-weight:
bold;">onClick="update();</span>"></span><br
style="color: rgb(153, 0, 0);">
<span style="color: rgb(153, 0, 0);">ART015010
ART</span><br
style="color: rgb(153, 0, 0);">
<span style="color: rgb(153, 0,
0);">African</span><br
style="color: rgb(153, 0, 0);">
<br style="color: rgb(153, 0, 0);">
<span style="color: rgb(153, 0, 0);"><br
/><input
type="checkbox" name="AC" id="AC" value="ART
American General " <span
style="font-weight:
bold;">onClick="update();</span>"></span><br
style="color: rgb(153, 0, 0);">
<span style="color: rgb(153, 0, 0);">ART015020
ART</span><br
style="color: rgb(153, 0, 0);">
<span style="color: rgb(153, 0,
0);">American</span><br
style="color: rgb(153, 0, 0);">
<span style="color: rgb(153, 0,
0);">General</span><br
style="color: rgb(153, 0, 0);">
<br style="color: rgb(153, 0, 0);">
<span style="color: rgb(153, 0, 0);">..................
</span><br style="color: rgb(153, 0, 0);">
<span style="color: rgb(153, 0, 0);">...</span><br
style="color: rgb(153, 0, 0);">
<br style="color: rgb(153, 0, 0);">
<span style="color: rgb(153, 0,
0);"></form></span><br>
<br>
Pls, suggest what I''m missing.<br>
<br>
Thanxs<br>
~Gurcharan<br>
<br>
<br>
<div><span class="gmail_quote">On 10/10/06, <b
class="gmail_sendername">Christophe Porteneuve aka TDD</b>
<<a
href="mailto:tdd-x+CfDp/qHev2eFz/2MeuCQ@public.gmane.org">tdd-x+CfDp/qHev2eFz/2MeuCQ@public.gmane.org
</a>> wrote:</span>
<blockquote class="gmail_quote"
style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt
0.8ex; padding-left: 1ex;"><br>
Hey there,<br>
<br>
Gurcharan Singh a écrit :<br>
> Form.getInputs
(''FormName'',[''checkbox'']). But on the
submission of the<br>
> form I''m getting the error message - HTML has no
properties.<br>
<br>
Try Form.getInputs(''FormId'',
''checkbox'').<br>
<br>
a) You need the *id* of the form, not its *name* (btw, XHTML 1.0<br>
deprecated ''name'' attributes for just about anything except
form
*fields*).<br>
<br>
b) You pass a string, not an array of strings, as a second argument.<br>
<br>
''HTH<br>
<br>
--<br>
Christophe Porteneuve aka TDD<br>
<a
href="mailto:tdd-x+CfDp/qHev2eFz/2MeuCQ@public.gmane.org">tdd-x+CfDp/qHev2eFz/2MeuCQ@public.gmane.org</a><br>
<br>
<br>
</blockquote>
</div>
<br>
<br clear="all">
<br>
-- <br>
<a
href="http://www.digitalmediainitiatives.com">www.digitalmediainitiatives.com</a>
<br>
<br>
</blockquote>
<br>
--~--~---------~--~----~------------~-------~--~----~<br>
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Spinoffs" group. <br> To post to this
group, send email to
rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org <br> To
unsubscribe from this group, send email to
rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
<br> For more options, visit this group at
http://groups.google.com/group/rubyonrails-spinoffs <br>
-~----------~----~----~----~------~----~------~--~---<br>
</body>
</html>
<br>