I get error message when i try to post this.
<?php
$intAssetHiddenTrue = "";
if ($_POST['hiddenTrue']) {
$intAssetHiddenTrue = $_POST['hiddenTrue'];
?>
<input type="radio" name="hiddenTrue" value="True" />True<br />
<input type="radio" name="hiddenTrue" value="False" />False<br />
Radio button not working
Page 1 of 13 Replies - 210 Views - Last Post: 02 October 2012 - 11:52 AM
#1
Radio button not working
Posted 02 October 2012 - 11:01 AM
Replies To: Radio button not working
#2
Re: Radio button not working
Posted 02 October 2012 - 11:35 AM
And what would that error message be? - It's one thing knowing there is an error, and a completely different thing knowing what that error is. PHP prints those messages for a reason.
I can tell you, however, that using a $_POST value that wasn't sent will generate a "Undefined index" notice.
The last two there will both check if the key exists before trying to use it, thus avoiding said error notice. The last one will also verify that the key has a non-empty value, which the isset() function will not. Usually you'll want to use empty().
I can tell you, however, that using a $_POST value that wasn't sent will generate a "Undefined index" notice.
/** Don't do this: **/
if ($_POST["key"]) {
// Do stuff with key...
}
/** Do this: **/
if (isset($_POST["key"])) {
// Do stuff with key...
}
/** Or, when appropriate, this: **/
if (!empty($_POST["key"])) {
// Do stuff with key...
}
The last two there will both check if the key exists before trying to use it, thus avoiding said error notice. The last one will also verify that the key has a non-empty value, which the isset() function will not. Usually you'll want to use empty().
#3
Re: Radio button not working
Posted 02 October 2012 - 11:38 AM
#4
Re: Radio button not working
Posted 02 October 2012 - 11:52 AM
I apologize for not posting the whole code here. Surprisingly, all I had to do was to copy/paste the entire code in a new file. It is working now.
Thanks both of you for the help, though! I sure will use this method suggested by you guys.
Did not mean to waste your time. Sorry!
Thanks both of you for the help, though! I sure will use this method suggested by you guys.
Did not mean to waste your time. Sorry!
Page 1 of 1
|
|

New Topic/Question
Reply



MultiQuote




|