Hello
I am having a tough time with radio buttons. All I want to accomplish is this :
I have queried and got a set of place names from my mysql db and i have listed it in php form with the use of radio buttons. When the user clicks on a radio button, i want to send that info to the server but NOT with submit button. And also display the form again with the selected radio button. As soon as the user clicks on the radio, I am using the onClick() event of radio button
echo "<input type='radio' name='placeChoice' value='$placeRecord[locationID]' onClick='reloadWPlace(this.form);'";
and i am calling the foll javascript function:
function reloadWPlace(form){
var placeVal=0;
var i;
for(i = 0; i < document.dataEntry.placeChoice.length; i++ )
{
if( document.dataEntry.placeChoice.checked == true )
placeVal = document.dataEntry.placeChoice.value;
}
self.location='dataEntry.php?placeChoice=' + placeVal;
}
When this js is executed, I append the place chosen to the address bar.
Then I also grab the selection from $_REQUEST[placeChoice] and assign it to $selPlace. I do this to set the appropriate radio button as "checked" when the form is displayed after reload. The whole chunk is here
echo "<br/>List of Places<br/><br/>";
while($placeRecord= mysql_fetch_array($placeSet)){
echo "<input type='radio' name='placeChoice' value='$placeRecord [locationID]' onClick='reloadWPlace(this.form)';";
if ($placeRecord['locationID'] == $selPlace) {
echo "checked";
}
echo ">";
echo "<a href='placeDetails.php?id=$placeRecord[locationID]' onClick=\"return popup(this, 'Details')\">$placeRecord[place]</a><br/>";
}
But for some reason, nothing happens at all. When i select the radio button, the js function is not called, nothing is appended to the address bar and page is not reloaded with the selected radio button. What could be the problem. Any help would be grealy appreciated!