Jump to content

Radio Button Problem


creacon

Recommended Posts

My questionnaire form is mostly radio button groups (Yes/No), and when the submit button is pressed the answers must be saved to a MySQL table. I can't seem to figure out how to capture the answers into php to save them. Everything in the w3Schools references shows ONLY javascript, and ONLY shows how to set and clear them; nothing about how to find out which were checked by the user, nor how to get the information to the php script. Here's my php code:

   <?php	session_start();		if (isset($_POST['submit'])){		// Fetch a radio button to see what the response is.		$radiogp1 = $_POST["RadioGroup1"];	// This is the "Name" value for a radio button pair		echo "<br /> $radiogp1 <br />";		$radio1_1 = $_POST["RadioGroup1_1"];	// This is the "id" value of an individual radio button		echo "$radio1_1 <br />";		echo "HEY, We're Here";  // This should display no matter what, but it doesn't				echo '<META http-equiv="refresh" content="10;URL=WOTCPLogout.php">';//		header("Location: WOTCLogoff.php");}	else{		$arrappl = $_SESSION['sesarrappl'];		$applname = $arrappl[fullname].", DOB: ".$arrappl[dob];		}	?> 

And that's another thing; why is it so difficult to get php to display something on the page for debugging purposes? I have another page that echo's variables for debugging, and they display as they should, but this one doesn't. Instead, as soon as the submit button is pressed the form refreshes then after the 10 seconds goes away (at least that much works). This is so frustrating. I'm getting NOWHERE at a very high rate of speed.While waiting, I tried adding the following javascript (not that this will help me get the answers into php), and in the submit button I added: onClick="checkValue()"

  	function checkValue()	{		if (document.getElementById("RadioGroup1_1").checked==true)		{			alert("The No button was checked");		}		else		{			alert("It must've been the Yes button");		}	}

And it works IN REVERSE; when I check the Yes button I get the first alert, and when I check the No button I get the second one. Whaaaa?

Link to comment
Share on other sites

Thanks a bazillion, that link was a godsend! I put it's home page in my favorites.Also I found out why I wasn't seeing any displays. They were actually there, but it's extremely hard to read white on white. I accidentally highlighted the top of the page and Voila, there were the displays. Since this is a mockup page for testing purposes, I changed the bacground color, and now I can see my testing messages.It's really a shame that you can't diplay an alert box from php (or if you can, someone please tell me how).Anyway, thanks again for the help.
Link to comment
Share on other sites

You can echo javascript tags and drop whatever variables you want into the alert, if you really felt like going that far.

Link to comment
Share on other sites

You can echo javascript tags and drop whatever variables you want into the alert, if you really felt like going that far.
I'm not sure I know how to do that, but I'm gonna try the next time I have to display a debug message.Thanks for the post.
Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...