retaining value of radio buttons
Posted: Thu Sep 20, 2007 4:02 pm
feyd | Please use
Here is the javascript fn that i am calling
Then to display the selected radio button again I grab the selection from $_REQUEST[placeChoice] and assign it to $selPlace . The whole chunk is here. This includes the first code snippet in this post
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 greatly appreciated!
feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
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 capture the onclick event and i want to send the info regarding which button was clicked to the server. And also display the form again with the selected radio button. I do not want to use submit button here because this happens in the middle of a long data entry form and I have a submit button at the end of that form.Code: Select all
while($placeRecord= mysql_fetch_array($placeSet)){
echo "<input type='radio' name='placeChoice' value='$placeRecord[locationID]' onClick='reloadWPlace(this.form);'";
}Code: Select all
function reloadWPlace(form){
var placeVal=0;
var i;
for(i = 0; i < document.dataEntry.placeChoice.length; i++ )
{
if( document.dataEntry.placeChoice[i].checked == true )
placeVal = document.dataEntry.placeChoice[i].value;
}
self.location='dataEntry.php?placeChoice=' + placeVal; // append selectes place to address bar
}Code: Select all
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/>";
}feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]