Page 1 of 1

checkbox is missing from $_GET

Posted: Wed Apr 14, 2004 6:40 pm
by davidklonski
hi

I wrote this simple test program in file test.php:

Code: Select all

<?php

$arr = array_keys($_GET);
foreach ($arr as $key) {
	print $key . "<br>";	
}
?>

<html>
 <body>
  <form name="entry" method="GET" action="test.php">
   <input type="text" name="TX">
   <input type="checkbox" name="CH">
   <input type="submit">
   <input type="hidden" name="HD">
  </form>
 </body>
</html>
for some reason the checkbox is not being displayed as part of the $_GET array.

This is probably some stupid mistake on my part.
can anyone see it?

thanks in advance

Posted: Wed Apr 14, 2004 6:51 pm
by markl999
I can't reproduce it here, your script seems to work ok *shrug*

Posted: Wed Apr 14, 2004 6:58 pm
by RadixDev
What happens if you put a value to the checkbox?

Posted: Wed Apr 14, 2004 7:02 pm
by davidklonski
nothing new, the output is:
TX
HD

Posted: Wed Apr 14, 2004 7:30 pm
by Paddy
<input type="checkbox" name="CH[]">

Put an array value in there.

Posted: Thu Apr 15, 2004 3:49 am
by davidklonski
I did but still no checkbox...
It is as if the checkbox is not a part of the form

Posted: Thu Apr 15, 2004 4:11 am
by JayBird
you need to give the checkbox a value!

Code: Select all

<input type="checkbox" name="CH" value="checked">
The checkbox will ONLY appear if you have checked the check box

Mark

Posted: Thu Apr 15, 2004 4:53 am
by RadixDev
Bech100:-
RadixDev wrote:What happens if you put a value to the checkbox?
and he says:-
davidklonski wrote:I did but still no checkbox...
It is as if the checkbox is not a part of the form

Posted: Thu Apr 15, 2004 5:10 am
by JayBird
yeah, i saw that, but i am guessing, when you told him to put a value in, he just checked the box and didn't change the code. Thats why i actually gave code to confirm this.

When typing a reply, in your head you know what YOU mean, but someone reading it can interpret in an entirely different way.

Mark