Connecting Tech Pros Worldwide Help | Site Map

Form processing with checkbox ?

 
LinkBack Thread Tools Search this Thread
  #1  
Old July 17th, 2005, 04:58 AM
Jay
Guest
 
Posts: n/a
Default Form processing with checkbox ?

Hi everybody !

I am currently writing a webpage that displays a list of records (
each record has a checkbox associated with it) to allow users to
select any record they want to delete (much like in "hotmail" or
"yahoo" e-mail where u can select particular message to delete) ?

Anybody have any idea how to do it ?

And one more question, I like to write my page so that when the user
click on a checkbox associated with a record. That record (that row)
is highlighted (like in "hotmail"), anybody has any idea how to do it
?

Any idea, example in php would be greatly appreciated !

Thank you in advance !

Jay

  #2  
Old July 17th, 2005, 04:58 AM
Tim Van Wassenhove
Guest
 
Posts: n/a
Default Re: Form processing with checkbox ?

In article <5668e569.0404242205.4fc594b1@posting.google.com >, Jay wrote:[color=blue]
> Hi everybody !
>
> I am currently writing a webpage that displays a list of records (
> each record has a checkbox associated with it) to allow users to
> select any record they want to delete (much like in "hotmail" or
> "yahoo" e-mail where u can select particular message to delete) ?
>
> Anybody have any idea how to do it ?[/color]

Thus you go ahead, and write your html with checkboxes. You probably
have a unique id to identify each message. Pass that idea as the value
for each checkbox.

Next thing to do is use print_r($_REQUEST), print_r($_POST) and print_r($_GET) )in the script that processes the form. This should give you a good idea to find the values you need.
[color=blue]
> And one more question, I like to write my page so that when the user
> click on a checkbox associated with a record. That record (that row)
> is highlighted (like in "hotmail"), anybody has any idea how to do it
> ?[/color]

I think you're better off using JavaScript for that. With a decent
search engine you should be able to find a site called, alistapart, and
they recently had a similar table marker higlight article.

--
http://home.mysth.be/~timvw
  #3  
Old July 17th, 2005, 05:00 AM
Eric Stein
Guest
 
Posts: n/a
Default Re: Form processing with checkbox ?

Jay,
I know the example you gave isn't your real problem, but I'm using it
anyways:

messages.html:
<form action="deletemsg.php" method="post">
<input type="checkbox" name="msgID_1" value="yes" checked>
<input type="checkbox" name="msgID_2" value="yes" checked>
<input type="checkbox" name="msgID_3" value="yes" checked>
<input type="checkbox" name="msgID_4" value="yes" checked>
<input type="checkbox" name="msgID_5" value="yes" checked>
<input type="checkbox" name="msgID_6" value="yes" checked>
<input type="sumit" value="Delete them!">
</form>

deletemsg.php:
<?php

for($loopvar = 1; $loopvar <= 6; $loopvar++)
{
if ($_POST["msgID_" . $loopvar] == "yes")
{
//stuff to delete msg here
}
}

?>

Note: I didn't test this code. I might not work - tell me if you find
something wrong with it.
~Eric

My PGP public key: http://www.parabolagames.com/chem/pgppubkey.txt

"Jay" <artlover70@yahoo.com> wrote in message
news:5668e569.0404242205.4fc594b1@posting.google.c om...[color=blue]
> Hi everybody !
>
> I am currently writing a webpage that displays a list of records (
> each record has a checkbox associated with it) to allow users to
> select any record they want to delete (much like in "hotmail" or
> "yahoo" e-mail where u can select particular message to delete) ?
>
> Anybody have any idea how to do it ?
>
> And one more question, I like to write my page so that when the user
> click on a checkbox associated with a record. That record (that row)
> is highlighted (like in "hotmail"), anybody has any idea how to do it
> ?
>
> Any idea, example in php would be greatly appreciated !
>
> Thank you in advance !
>
> Jay[/color]


  #4  
Old July 17th, 2005, 05:00 AM
Jay
Guest
 
Posts: n/a
Default Re: Form processing with checkbox ?

Eric Stein wrote:[color=blue]
> Jay,
> I know the example you gave isn't your real problem, but I'm using it
> anyways:
>
> messages.html:
> <form action="deletemsg.php" method="post">
> <input type="checkbox" name="msgID_1" value="yes" checked>
> <input type="checkbox" name="msgID_2" value="yes" checked>
> <input type="checkbox" name="msgID_3" value="yes" checked>
> <input type="checkbox" name="msgID_4" value="yes" checked>
> <input type="checkbox" name="msgID_5" value="yes" checked>
> <input type="checkbox" name="msgID_6" value="yes" checked>
> <input type="sumit" value="Delete them!">
> </form>
>
> deletemsg.php:
> <?php
>
> for($loopvar = 1; $loopvar <= 6; $loopvar++)
> {
> if ($_POST["msgID_" . $loopvar] == "yes")
> {
> //stuff to delete msg here
> }
> }
>
> ?>
>
> Note: I didn't test this code. I might not work - tell me if you find
> something wrong with it.
> ~Eric
>
> My PGP public key: http://www.parabolagames.com/chem/pgppubkey.txt
>
> "Jay" <artlover70@yahoo.com> wrote in message
> news:5668e569.0404242205.4fc594b1@posting.google.c om...
>[color=green]
>>Hi everybody !
>>
>>I am currently writing a webpage that displays a list of records (
>>each record has a checkbox associated with it) to allow users to
>>select any record they want to delete (much like in "hotmail" or
>>"yahoo" e-mail where u can select particular message to delete) ?
>>
>>Anybody have any idea how to do it ?
>>
>>And one more question, I like to write my page so that when the user
>>click on a checkbox associated with a record. That record (that row)
>>is highlighted (like in "hotmail"), anybody has any idea how to do it
>>?
>>
>>Any idea, example in php would be greatly appreciated !
>>
>>Thank you in advance !
>>
>>Jay[/color]
>
>
>[/color]

I usually do it like this:

messages.html:
<form action="deletemsg.php" method="post">
<input type="checkbox" name="msgID[]" value="1" checked>
<input type="checkbox" name="msgID[]" value="2" checked>
<input type="checkbox" name="msgID[]" value="3" checked>
....
<input type="checkbox" name="msgID[]" value="x" checked>
<input type="submit" value="Delete them!">
</form>

deletemsg.php:
<?php

$idarray = '(' . implode(',', $_POST['msgID']) . ')';
$query = "DELETE FROM `table` WHERE msgID IN $idarray";
// Process query here

?>

  #5  
Old July 17th, 2005, 05:04 AM
Jay
Guest
 
Posts: n/a
Default Re: Form processing with checkbox ?

Jay <user@isp.tld> wrote in message news:<408ecdb8$1_1@newspeer2.tds.net>...[color=blue]
> Eric Stein wrote:[color=green]
> > Jay,
> > I know the example you gave isn't your real problem, but I'm using it
> > anyways:[/color][/color]

It is my real problem actually. The real webpage is a little bit more
complicated than this. But I got stuck at the checkbox thing. Thank
for your help though. I am glad my problem is solved.

Thanks

Jay
 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,989 network members.