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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Radio button selection 1

Status
Not open for further replies.

Niavlys

IS-IT--Management
Jun 3, 2002
197
CA
Hi,
I want to have a radio button selection for a user to select from one page or another with a button. It's seems simple but I can't figure how to do it. I have something like this:
Code:
<form name=&quot;f_Choice&quot;>
    <input type=&quot;radio&quot; name=&quot;choice&quot; value=&quot;\page1.asp&quot; 
    <input type=&quot;radio&quot; name=&quot;choice&quot; value=&quot;\page2.asp&quot;>
    <p align=&quot;center&quot;><input type=&quot;button&quot; value=&quot;Continue&quot; onClick=&quot;choice.value&quot;>      
</form>

Can someone help me please!
Thanks in advance.
 
If you mean:
Code:
<p align=&quot;center&quot;><input type=&quot;button&quot; value=&quot;Continue&quot; onClick=&quot;window.location&quot;>

nothing happens, I get no errors but there's no results.



 
<script language=&quot;javascript&quot;>
function goToSelectedPage()
{
var chk = document.f_Choice.choice
for( i=0; i<chk.length; ++i)
if( chk.checked)
window.location = chk.value;
}
</script>
</head>
<body style=&quot;overflow:hidden;&quot;>
<form name=&quot;f_Choice&quot;>
<input type=&quot;radio&quot; name=&quot;choice&quot; value=&quot;sqltest.htm&quot;>
<input type=&quot;radio&quot; name=&quot;choice&quot; value=&quot;sqltest.htm&quot;>
<p align=&quot;center&quot;>
<input type=&quot;button&quot; value=&quot;Continue&quot; onClick=&quot;goToSelectedPage()&quot;>
</p>
</form> _________________________________________________________
for the best results to your questions: FAQ333-2924
Is your question a most FAQ?? Find out here FAQ333-3048
 
sorry,
<script language=&quot;javascript&quot;>
function goToSelectedPage()
{
var chk = document.f_Choice.choice
for( x=0; i<chk.length; x++)
if( chk[x].checked)
window.location = chk[x].value;
}
</script>
</head>
<body style=&quot;overflow:hidden;&quot;>
<form name=&quot;f_Choice&quot;>
<input type=&quot;radio&quot; name=&quot;choice&quot; value=&quot;sqltest.htm&quot;>
<input type=&quot;radio&quot; name=&quot;choice&quot; value=&quot;sqltest.htm&quot;>
<p align=&quot;center&quot;>
<input type=&quot;button&quot; value=&quot;Continue&quot; onClick=&quot;goToSelectedPage()&quot;>
</p>
</form> _________________________________________________________
for the best results to your questions: FAQ333-2924
Is your question a most FAQ?? Find out here FAQ333-3048
 
you could make this easy though and simple do
<input type=&quot;radio&quot; name=&quot;choice&quot; onClick=&quot;window.location = 'page1.asp'&quot;>

this would be the cleanest way to do it. _________________________________________________________
for the best results to your questions: FAQ333-2924
Is your question a most FAQ?? Find out here FAQ333-3048
 
OK,
The I tried your second example, it works but it doesn't wait for button click to execute.

I also tried the first exemple but nothing happens when I click button.

Thank you.
 
did you change the pages I used to test it??

the second example doesn't use buttons, when they click the radio it goes to the page _________________________________________________________
for the best results to your questions: FAQ333-2924
Is your question a most FAQ?? Find out here FAQ333-3048
 
yes, I changed it to value=&quot;../Tools/Unlock.asp&quot;
and value=&quot;../Tools/Reset.asp&quot;

Is there a way to print the content of chk in Javascript function. I don't know anything about Javascript.

I tried Response.Write chk; and I get an &quot;;&quot; missing error
 
response.write is a server side write event
try
document.write

if you still have problems show the code you have

I did notice a made a error when changing my i's for the italic's
here
for( x=0; x<chk.length; x++)
you nee to change that one _________________________________________________________
for the best results to your questions: FAQ333-2924
Is your question a most FAQ?? Find out here FAQ333-3048
 
Thank you, it works! I should now read a bit on Javascript...



Would it be possible to do the same thing using vbscript?
 
never tried it but yes it would be possible in vbscript but that would restrict you to IE only then. when it comes to the client level javascript is far more capable then vbscript. deffinetely take some time to learn a bit on some of the common functions.

glad I helped you out a bit and thanks for the star. _________________________________________________________
for the best results to your questions: FAQ333-2924
Is your question a most FAQ?? Find out here FAQ333-3048
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top