Ok I have a form the person puts in their name and chooses their country. That posts via ajax to see if they are in the DB. If something is found it puts the name address etc in a form and asks for them to verify that this is indeed them. So far we are good. The problem arises with this second 'verify' form it is shown here:

echo "<form action=\"show.php?p=c2\" method=\"post\" onsubmit=\"return false;\">\n";
		echo "<h3 class=org>Returning ";
		if($_POST['dtype']=='F'){
			echo "Food Vendor";
		}else{
			echo "Artist";
		}
		echo "</h3>\n";
		echo "<table class=ctrbrdr>\n";
		echo "<tr><td><h4 class=org2>Name:</h4></td><td>".$row->ownfirst." ".$row->ownlast."</td></tr>\n";
		echo "<tr><td><h4 class=org2>Address on File:</h4></td><td>".$row->addr."<br>".$row->city.", ".$row->st."&nbsp;&nbsp;".$row->zip."</td></tr>\n";
		echo "</table>\n";
		echo "<input type=hidden name=country id=country value=\"".$_POST['country']."\">";
		echo "<input type=hidden name=dtype id=dtype value=\"".$_POST['dtype']."\">";
		echo "<input type=hidden id=sid name=sid value=\"".$_POST['sid']."\">\n";
		echo "<input type=radio name=verify id=fred value=\"NO\" >No Sorry this is Someone Else<br>";
		echo "<input type=radio name=verify id=fred value=\"YES\" checked>YES This is ME<br>\n";
		echo "<input type=\"submit\" class=bigbut value=\"Submit\" onClick=\"sendRequest2()\">\n";
		echo "</form>\n";

it is submitted via ajax here is the ajax part in the header:

<script type="text/javascript" src="bits/prototype.js"></script>
 <script type="text/javascript">
function sendRequest2() {
		new Ajax.Request("show.php?p=c2",{
		method: 'post',
		parameters: 'sid='+$F('sid')+'&fred='+$F('fred')+'&country='+$F('country')+'&dtype='+$F('dtype'),
		onComplete: showResponse
		});
	}

function showResponse(req){
$('cont').innerHTML= req.responseText;
}

</script>

So the weird part. The radio button doesn't exactly work right. If the first one is chosen I get the appropriate value.
As shown here I would get 'NO' in the $POST['fred'] variable if I choose NO and If I choose Yes the second button I get 'NULL' in the $POST['fred'] variable. However, if I put the YES radio button first I will get 'YES' in the variable if I choose Yes and now I get NULL in variable if I choose NO.

I can't find anything wrong with the radio buttons. And all the other variables come through fine. But if I switch the location of the buttons the value that comes through changes. No other change just the order of the button in the code. WTF??? Can anyone tell me what sort of gremlin I've encountered here? :eek:

    Ok so in the script parameters the first instance is the id and the second is the form element?? Is that correct? ie: '&fred='+$F('fred') so since the html radio buttons do need to have the same name I would need something along the lines of '&fredy='+$F('fred')+'&fredn='+$F('fred') for the yes and no buttons??? is this correct or am I totally missing how this works?

    Thanks for the links they did answer another of my questions the what is the $F for.

    Then when it gets posted for processing would it still get addressed the same as a normal html radio button??? ie: would $_POST['fred'] have either a 'YES' or a 'NO' value???

      Write a Reply...