Newsgroup: it.comp.lang.javascript
Titolo: JavaScript on (all) checkboxes without <form> tab

Hello all,
I'm a (armature) PHP programmer, and I believe that I can't to what I
want in PHP and it appears that JavaScript is the best way. I'm
wondering if someone could point me in the right direction so I know
that I'm at least heading in the right direction.
PROBLEM: I have a page (dynamically created) with multiple, three
(text) field forms running horizontal. I would like to create another
form (checkboxes ONLY) running vertical over the entire page. This
does not work with straight HTML. My question is: Can I make the
"Submit" button parse the entire page looking for checkboxes and if
"on" Enter that value into an array/string/? and then pass that info
to page 'X' as a METHOD="PUT" value?
Thanks for any help!
--Gene

I don't know if I understood right, if yes I think you can do something like
that:
...write an hidden form...
<form name="myform" method="post" action="NextPage">
    <input type="hidden" name="FirstField" value="" />
    <input type="hidden" name="SecondField" value="" />
    <input type="hidden" name="CheckBoxField1" value="" />
    <input type="hidden" name="CheckBoxField2" value="" />
</form>
...make a JavaScript function to check all your field on the page (text
Field and checkBox)...
function CheckallField()
{
document.getElementById("FirstField").value=document.getElementById("Field1"
).value;
document.getElementById("SecondField").value=document.getElementById("Field2
").value;
document.getElementById("CheckBoxField1").value=document.getElementById("Che
ckField_1").checked;
document.getElementById("CheckBoxField2").value=document.getElementById("Che
ckField_2").checked;
}
...in the page...
<form name="form1">
    <input type="text" name="Field1" id="Field1" value="" />
</form>
<form name="form2">
    <input type="checkbox" name="CheckField_1" id="CheckField_1" />
</form>
<form name="form3">
    <input type="text" name="Field2" id="Field1" value="" />
</form>
<form name="form4">
    <input type="checkbox" name="CheckField_2" id="CheckField_2" />
</form>
...and at the end of the page put a button...
<form name="end">
<input type="button" name="EndButton" value="Submit"
onclick="CheckallField()"/>
</form>
Let me know if it works...
"GeneL" <gla...@nillspamBU.edu> ha scritto nel messaggio
news:tb31evk53qbdtlelv...@4ax.com...


Took me a bit to figure it out (Not being a Javascript user), But I
think this is just what I need! I peared it down a bit and added a few
little PHP things so *I* could understand it a bit, but this is what I
came up with: (Many thanks!!!)
//---start code
<?php
print_r($_POST);
echo "CheckBoxField1 = $CheckBoxField1<br>\n";
echo "CheckBoxField2 = $CheckBoxField2<br>\n";
?>
<SCRIPT LANGUAGE="JavaScript">
<!--
function CheckallField()
{
document.getElementById("CheckBoxField1").value =
document.getElementById("CheckField_1").checked;
document.getElementById("CheckBoxField2").value =
document.getElementById("CheckField_2").checked;
document.myform.submit()
}//-->
</SCRIPT>
<form name="form2">
    <input type="checkbox" name="CheckField_1" id="CheckField_1" />
</form>
<form name="form4">
    <input type="checkbox" name="CheckField_2" id="CheckField_2" />
</form>
<form name="myform" method="post" action="<?= $_SERVER["PHP_SELF"]
?>">
<input type="hidden" name="CheckBoxField1" value="" />
<input type="hidden" name="CheckBoxField2" value="" />
<input type="button" name="EndButton" value="Submit" 
onclick="CheckallField()"/>
</form>
//---end code
