|
-
Apr 3rd, 2001, 07:17 PM
#1
Thread Starter
Fanatic Member
a javascript question.
i have three radio buttons and I want to, on form submit, verify what one has been choose.
I am trying this:
var strURL=document.frmEvent.txtURL.value;
var optionButtonSelected=document.frmEvent.inpURL.checked;
alert(optionButtonSelected);
this is inside the function called by the submit button.
i have the names correct.
the form is called frmEvent and there is a text field called txtURL and the radio buttons are all called inpURL.
as you can see i have an alert to get the value from the checked radio but it comes back 'undifined'
so what am i doing wrong?
any suggestions are welcome,
if you need more information , just ask.
thanks
-
Apr 4th, 2001, 07:38 AM
#2
Frenzied Member
try this:
Code:
<HTML>
<HEAD>
<script language=javascript>
function x(){
var strURL=document.frmEvent.txtURL.value;
var optionButtonSelected=-1;
for(var i=0;i<document.frmEvent.inpURL.length;i++)
{
if(document.frmEvent.inpURL(i).checked==true)
{
optionButtonSelected = i;
}
}
if(optionButtonSelected==-1)
{
alert("Please select and option")
}else{
alert(optionButtonSelected);
}
}
</script>
</HEAD>
<BODY>
<form name=frmEvent>
<input name=txtURL>
<INPUT name=inpURL type=radio> option 1<BR>
<INPUT name=inpURL type=radio> option 2<BR>
<INPUT name=inpURL type=radio> option 3<BR>
<input type=button onClick="x();">
</form>
</BODY>
</HTML>
-
Apr 4th, 2001, 03:30 PM
#3
Thread Starter
Fanatic Member
thanks,
turns out i'm not doing it this way but i'll be putting that code into my 'javascript' library.
thanks again Mark
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|