ianatkins
07-14-2005, 12:39 PM
Hello,
Javascript is not my specialty so I would greatly appriciate any help anyone can give.
My Problem:
I have a form with several check boxes. These are categories for a seach field.
When a user checks different boxes on submit I want the values for the "selected" check boxes to be concatenated into a field.
Currently I have an onclick of the checkbox which concatenates the values into a field. The problem with this is when some one unselects a checkbox the value is still left / added again to the concatenated field.
So the javascript concatenate needs to be on the form submit when the user is happy with their selections, and only for the selected check boxes.
Here is my simple current code:
<form action="" method="get" name="categories">
<table cellspacing="2" cellpadding="2" border="0">
<tr>
<td><input name="inter" type="checkbox" value="International Films" onclick="this.form['category'].value=this.form['category'].value + ' ' + this.form['inter'].value;"></td><td>International Films</td>
<td><input name="conferences" type="checkbox" value="Conferences" onclick="this.form['category'].value=this.form['category'].value + ' ' + this.form['conferences'].value;"></td><td>Conferences</td>
</tr>
<tr>
<td><input name="adverts" type="checkbox" value="Adverts" onselect="this.form['category'].value=this.form['category'].value + ' ' + this.form['adverts'].value;"></td><td>Adverts</td>
<td><input name="corporate" type="checkbox" value="Conferences" on></td><td>Corporate Films</td>
</tr>
<tr>
<td colspan="4"><input name="category" type="text" style="width:500px"></td>
</tr>
</table>
</form>
Any help would be appriciated,
Thanks
Ian.
Javascript is not my specialty so I would greatly appriciate any help anyone can give.
My Problem:
I have a form with several check boxes. These are categories for a seach field.
When a user checks different boxes on submit I want the values for the "selected" check boxes to be concatenated into a field.
Currently I have an onclick of the checkbox which concatenates the values into a field. The problem with this is when some one unselects a checkbox the value is still left / added again to the concatenated field.
So the javascript concatenate needs to be on the form submit when the user is happy with their selections, and only for the selected check boxes.
Here is my simple current code:
<form action="" method="get" name="categories">
<table cellspacing="2" cellpadding="2" border="0">
<tr>
<td><input name="inter" type="checkbox" value="International Films" onclick="this.form['category'].value=this.form['category'].value + ' ' + this.form['inter'].value;"></td><td>International Films</td>
<td><input name="conferences" type="checkbox" value="Conferences" onclick="this.form['category'].value=this.form['category'].value + ' ' + this.form['conferences'].value;"></td><td>Conferences</td>
</tr>
<tr>
<td><input name="adverts" type="checkbox" value="Adverts" onselect="this.form['category'].value=this.form['category'].value + ' ' + this.form['adverts'].value;"></td><td>Adverts</td>
<td><input name="corporate" type="checkbox" value="Conferences" on></td><td>Corporate Films</td>
</tr>
<tr>
<td colspan="4"><input name="category" type="text" style="width:500px"></td>
</tr>
</table>
</form>
Any help would be appriciated,
Thanks
Ian.