CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
Help me how to do this

 



datlaravi
Deleted

Jun 13, 2000, 7:21 AM

Post #1 of 4 (526 views)
Help me how to do this Can't Post

Hi,
I am working on Search screen. I have 4 checkboxes in the form and one text box. I am
posting that form to the cgi script. I am using CGI.pm. How do i know whether the checkbox has been checked?
Can i say, if(defined($nameOfBox)) Does this work?
If the user has checked all the 4 checkboxes, can i put all the checked values in an array?
I want to process each of them with the database value. Please help me how to do this
Thanks for your help


Cure
User

Jun 17, 2000, 9:14 AM

Post #2 of 4 (526 views)
Re: Help me how to do this [In reply to] Can't Post

By default, when a user puts a check in the checkbox the value will be on.

To see if a user has check the checkbox do this

if($q->param('name_of_field')
{
print 'the user has putten a check in the checkbox'
}
else
{
print 'the user didnt put a check in the checkbox'
}

So basically do a if statement.

To get all the values of the checks in all the checkboxes do this

@check = $q->param('name_of_field');

example:

<form>
<input type=checkbox name=cure value=0>
<input type=checkbox name=cure value=1>
</form>


@check = $q->param('name_of_field');
now @check will have value 0 and 1 if both of them were checked.

Cure


[This message has been edited by Cure (edited 06-17-2000).]


Kanji
User / Moderator

Jun 17, 2000, 2:12 PM

Post #3 of 4 (526 views)
Re: Help me how to do this [In reply to] Can't Post

if ($q->param('name_of_field')) { ... } doesn't work if name_of_field was set to 0, so use of defined() is warranted.


Cure
User

Jun 17, 2000, 2:32 PM

Post #4 of 4 (526 views)
Re: Help me how to do this [In reply to] Can't Post

OOPS I meant to put that in there

Cure

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives