By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,385 Members | 1,767 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,385 IT Pros & Developers. It's quick & easy.

Inserting checkbox values into text field

P: n/a
Hi

Was wondering if anyone could help me with this problem :

If I have three checkboxes with different values on a form like :

<input type="checkbox" name="checkbox" value="1stValue">
<input type="checkbox" name="checkbox" value="2ndValue">
<input type="checkbox" name="checkbox" value="3rdValue">

And I needed to submit that form so that the values end up in a text field
called CHECKBOX_TERMS with an AND in between each, so that the text field
on the same form has in effect '1stValue AND 2ndValue AND 3rdValue'
contained within it.

Which is the best way to do it ?

Thanks

JT


Sep 8 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a
J Talbot wrote:
If I have three checkboxes with different values on a form like :
<input type="checkbox" name="checkbox" value="1stValue">
<input type="checkbox" name="checkbox" value="2ndValue">
<input type="checkbox" name="checkbox" value="3rdValue">
And I needed to submit that form so that the values end up in a text field
called CHECKBOX_TERMS with an AND in between each, so that the text field
on the same form has in effect '1stValue AND 2ndValue AND 3rdValue'
contained within it.

Which is the best way to do it ?
To change the server side script.

Something along the lines of:

my $CHECKBOX_TERMS;
my $sep = "";
foreach my $checkbox ($cgi->param('checkbox')) {
$CHECKBOX_TERMS .= $sep . $checkbox;
$sep = " AND ";
}

Sep 8 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.