|
-
May 18th, 2002, 10:20 AM
#1
Thread Starter
Addicted Member
checkboxes with the same name!!!??
hello,
if i have many checkboxes with the same name but different values,,,like this:
PHP Code:
<form method="post" action="order.php">
<input type="checkbox" name="cart" value="123.com">
<input type="checkbox" name="cart" value="123.org">
<input type="checkbox" name="cart" value="123.net">
<input type="checkbox" name="cart" value="123.biz">
<input type="submit" name="b1" value="buy now">
</form>
now when i submit the form, i want to print only the checked items,, note that all of them have the same name,,,please help
thanx alot...
-
May 18th, 2002, 06:01 PM
#2
Fanatic Member
do this:
PHP Code:
<form method="post" action="order.php">
<input type="checkbox" name="cart[0]" value="123.com">
<input type="checkbox" name="cart[1]" value="123.org">
<input type="checkbox" name="cart[2]" value="123.net">
<input type="checkbox" name="cart[3]" value="123.biz">
<input type="submit" name="b1" value="buy now">
</form>
Then cycle through them like so:
PHP Code:
for ($i=0;$i<4;$i++)
if ($cart[$i] != "")
print "$cart[$i]<br>\n";
-Matt
-
May 20th, 2002, 09:07 AM
#3
don't even have to do that. you don't need the numbers in there.
PHP Code:
<form method="post" action="order.php">
<input type="checkbox" name="cart[]" value="123.com">
<input type="checkbox" name="cart[]" value="123.org">
<input type="checkbox" name="cart[]" value="123.net">
<input type="checkbox" name="cart[]" value="123.biz">
<input type="submit" name="b1" value="buy now">
</form>
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|