Friday, 6 September 2013

PHP How get at values for a list of buttons

PHP How get at values for a list of buttons

I want a list of buttons in a form and on postback I'd like to interrogate
the list to see what status the buttons are at (by background colour if
you are interested.)
The following codes says that Buttonx is undefined
However using the text boxes it works fine.
In javascript I can get at the array of buttons - at least in my real
program.
If this is not possible, and an explanation would be useful, does anyone
have a workaround at how I can get at the buttons in my postback. (In the
real code the buttons are dynamically created depending on an sql query
list)
<?php
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
var_dump($_POST['Buttonx']);
}
?>
<form name="RegisterStudents" action="" method="post">
<button type="submit" name="myButton">Submit</button>
<!--
<input type="text" name="Buttonx[]" id="B0" value="0" />
<input type="text" name="Buttonx[]" id="B1" value="1" />
<input type="text" name="Buttonx[]" id="B2" value="2" />
<input type="text" name="Buttonx[]" id="B3" value="3" />
-->
<button type="button" name="Buttonx[]" id="B0" >0</button>
<button type="button" name="Buttonx[]" id="B1" >1</button>
<button type="button" name="Buttonx[]" id="B2" >2</button>
<button type="button" name="Buttonx[]" id="B3" >3</button>
</form>
Thanks Gordon

No comments:

Post a Comment