HTML checkboxes/forms

admin

Administrator
Staff member
Hope this question hasn't already answered elswhere..but here it is!<br />
<br />
I'm developing an IIS application using VB 6 and of course HTML as the front end interface. In one case i am trying to submit an HTML form that contains checkboxes. There is not a problem in submitting the checkboxes ...however in each row that has a checkbox i am also including an input field (a TEXTAREA). The problem is, when i submit the form it passes and combines the data from all the input boxes for each checkbox that was checked and even those which were not checked, instead of separating them accordingly. Confused eh?<br />
<br />
Here's a code sample..<br />
<form name="frmContent" action=default.asp method="POST"><br />
<tr><br />
<td><input type="checkbox" name="whatever"></td><br />
<td><TEXTAREA cols=10 rows=3 name="INFO"></textarea></td><br />
</tr><br />
<img type=button value=submit><br />
</form><br />
<br />
So say we have 5 items represented by code similar to the above. When submitted after clicking on which checkbox you want to pass, the "INFO" TEXTAREA is submitted and combined for ALL of the checkboxes, regardless of whether they were checked off or not. The information is being retrieved by the form request object in VB.<br />
<br />
Hope this wasn't too confusing! And i appreciate any assitance! :)<br />
Thanks<!--content-->If you have a form, it will send all the form data to your script embedded between the start form tag and end form tag. Its then up to your script to determine what to do with the data. If you only want the textarea data associated with a specific checkbox you have to code your script to check if the appropriate checkbox is checked, then it slurps up the data in the textarea field and ignores the rest by not doing anything with that data or voiding that data.<br />
<br />
Another alternative is to have seperate forms for each checkbox/textarea combination which should be easy to do and should not change the appearance of your html code.<br />
<br />
<form name="frmContent1" action=default.asp method="POST"><br />
<tr><br />
<td><input type="checkbox" name="whatever"></td><br />
<td><TEXTAREA cols=10 rows=3 name="INFO"></textarea></td><br />
</tr><br />
<img type=button value=submit><br />
</form><br />
<form name="frmContent2" action=default.asp method="POST"><br />
<tr><br />
<td><input type="checkbox" name="whatever"></td><br />
<td><TEXTAREA cols=10 rows=3 name="INFO"></textarea></td><br />
</tr><br />
<img type=button value=submit><br />
</form><br />
<form name="frmContent3" action=default.asp method="POST"><br />
<tr><br />
<td><input type="checkbox" name="whatever"></td><br />
<td><TEXTAREA cols=10 rows=3 name="INFO"></textarea></td><br />
</tr><br />
<img type=button value=submit><br />
</form><br />
<form name="frmContent4" action=default.asp method="POST"><br />
<tr><br />
<td><input type="checkbox" name="whatever"></td><br />
<td><TEXTAREA cols=10 rows=3 name="INFO"></textarea></td><br />
</tr><br />
<img type=button value=submit><br />
</form><br />
<form name="frmContent5" action=default.asp method="POST"><br />
<tr><br />
<td><input type="checkbox" name="whatever"></td><br />
<td><TEXTAREA cols=10 rows=3 name="INFO"></textarea></td><br />
</tr><br />
<img type=button value=submit><br />
</form><br />
<form name="frmContent6" action=default.asp method="POST"><br />
<tr><br />
<td><input type="checkbox" name="whatever"></td><br />
<td><TEXTAREA cols=10 rows=3 name="INFO"></textarea></td><br />
</tr><br />
<img type=button value=submit><br />
</form><br />
<br />
<br />
something along those lines. Just make sure the HTML code is correct, its not correct in my above example.<!--content-->Yes i think i will have to go with the option of using some kind of javascript to make sure i only submit rows of data which are checked. The other option would just be too messy for my case.<br />
<br />
Thanks for your advice!<!--content-->javascript being client side is easy to override, better to do it server side with a script for best results, but if you believe javascript will suit your needs you can do that.<!--content-->
 
Back
Top