Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Finding Value of a Checkbox and unchecking it

Status
Not open for further replies.

waiterm

Programmer
May 17, 2004
236
GB
Hi,

I've been trying to find the value of a checkbox first using and then using HTML::Form, I've also just realised that the attributes of the checkbox suggests that no value has been assigned:
Code:
<INPUT type=checkbox CHECKED name=club_info>
What is the default value of the checkbox in this case?

I'm actually trying to uncheck the box using Mechanize, however I keep on getting the following error:
Code:
No checkbox "club_info" for value "" in form at...
I've tried True/False/""/0/1 but can't seem to find the correct value and hence the error keeps on popping up.

Any ideas/thoughts would be gratefully accepted.

Rob Waite
 
Why dont you

use CGI;

parse every value from your form to a cgi object,

and check if '$query->param('club_info')' is true.

if its not true (which means that it is Not checked)then you can check it like this
Code:
print $query->checkbox( -name=>'club_info',
                        -values=>[club_info],
                        -default=>'club_info');

which gives you a checked checkbox

or if it is true (which means that it is checked)then you can Uncheck it like this
Code:
print $query->checkbox( 'club_info');

which gives you an unchecked checkbox

or if you want to do it with HTML then for an empty checkbox is like this
Code:
<input type="checkbox" name="club_info" value="club_info" />Club Info<br />
and for a checked checkbox is like this
Code:
<input type="checkbox" name="club_info" value="club_info" checked="checked" />Club Info<br />
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top