Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Findind value of Radio clicked - Without Event

Status
Not open for further replies.

nsarun

IS-IT--Management
Nov 5, 2003
6
US
Dear Folks,

I have a radio group at the top of my form. In another section I have a button. When this is clicked, a pop-up opens out. Now the page for this pop-up depends on the radio button checked. I am doing something like this.

function modSel(){

if(document.pngen.system.value=="C")
popUp('ModSelect2.htm');
else
popUp('ModSelect1.htm');
}
The document.pngen.system.value is always 'undefined' even when a radio button is clicked. Am I missing something.

Will you help me, Please!!

Thanks
Arun
 
I have had loads of annoying afternoons spent with having objects being passed through.

what i suggest you do for a start is maybe change the name of the radio list from system to something that in no way could represent a javaScript something or other.

i.e. rdsystem

then maybe you should access the variable in a different way.
document.Form1.elements[toElement].value

document.FORMNAME.elements[YOURELEMENT].value

FORMNAME would be the name of your form and YOURELEMENT could be for instance rdsystem. Also be sure you get the correct casing of you object names aswell as that sometimes causes it. Just as a tip (sorry if you know this already) if things are not working properly then i usually create variables and then use window.alert(VARIABLE); output to the screen so at least i know what is going on.

I am not expert with JS infact i hate it becuase of all the late nights it has caused me. Anyway, hope this helps.

Rob
 
you are refrencing the wrong property of the radio button.

check this out:
Code:
<form name="daForm">
<input type="radio" name="daRadio" value="num1">
<input type="radio" name="daRadio" value="num2">
<input type="button" name="daButton" onclick="openWinViaRadio()">
</form>

Thats ur form. pay special attention to the names of the fields and such, as thats what the openWinViaRadio will be using. Heres your javascript:
Code:
function openWinViaRadio(){
if (document.daForm.daRadio[0].checked){
  popUp(....);
} else if (document.daForm.daRadio[1].checked){
  popUp(...);
}
}

Or something like that

Robert Carpenter
/b{2}|!b{2}/ - that is the question...
robert@convertingchaos.com
 
Try this sample page:

Code:
<html>
<head>
<script language="JavaScript">
<!--
function navAway() {
	var the_radio = document.the_form.radSys;
	var the_url = '';
	for (var i = 0; i < the_radio.length; i++) {
		if (the_radio[i].checked == true)
			the_url = the_radio[i].value;
	}
	document.location.href = the_url;
}
-->
</script>
<title>Test</title>
</head>
<body>
<form name="the_form">
<input type="radio" name="radSys" value="[URL unfurl="true"]http://www.google.com/">[/URL] Google<br>
<input type="radio" name="radSys" value="[URL unfurl="true"]http://www.yahoo.com/">[/URL] Yahoo!<br>
<input type="button" class="button" onclick="navAway();" value="go to page">
</form>
</body>
</html>

*cLFlaVA
----------------------------
Ham and Eggs walks into a bar and asks, "Can I have a beer please?"
The bartender replies, "I'm sorry, we don't serve breakfast.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top