Wrox Home  
Search P2P Archive for: Go

  Return to Index  

javascript_howto thread: Go to URL with radio buttons in a form


Message #1 by "Omar Esquivel" <omare@u...> on Mon, 5 Aug 2002 23:31:58
Hi,

Here you are - a working soloution. It works under MS browsers... NS I
don't know...

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
     <head>
          <title></title>
          <meta name=3D"GENERATOR" content=3D"Microsoft Visual Studio.N
ET 7.0">
          <meta name=3D"vs_targetSchema" content
=3D"http://schemas.microsoft.com/intellisense/ie5">
          <script language=3D"javascript">
          <!--
          function gotoURL() {
               var cAllRadios =3D myForm.elements.RadioGroup;
               var sURL;
               for(var i=3D0; i<cAllRadios.length; i++) {
                    if (cAllRadios[i].checked) {
                         sURL =3D cAllRadios[i].value;
                    }
               }
               if (sURL) {
                    document.location.href =3D sURL;
               } else {
                    alert('Please select URL to goto');
               }
          }
          //-->
          </script>
     </head>
     <body>
          <form action=3D"javascript:void(gotoURL())" method=3D"get" id

=3D"myForm" name=3D"myForm">
          JavaScript for Scared People<input id=3D"Radio1" type=3D"radi
o" value
=3D"http://www.anaesthetist.com/mnm/javascript/" name=3D"RadioGroup">&n
bsp;
          MSDN<input id=3D"Radio2" type=3D"radio" value
=3D"http://msdn.microsoft.com" name=3D"RadioGroup">&nbsp;
          Dynamic drive<input id=3D"Radio3" type=3D"radio" value
=3D"http://www.dynamicdrive.com/" name=3D"RadioGroup"><br>
          <input type=3D"submit" value=3D"Goto">
          </form>
     </body>
</html>


Med venlig hilsen

Sten Hougaard



                                                                       
                                           
                    Greg Griffiths                                     
                                           
                    <greg2@s...       To:     "JavaScript HowTo" <ja
vascript_howto@p...>               
                    .org>                cc:                           
                                           
                                         Subject:     [javascript_howto
] Re: Go to URL with radio buttons in a    
                    06-08-2002            form                         
                                           
                    20:54                                              
                                           
                    Please respond                                     
                                           
                    to "JavaScript                                     
                                           
                    HowTo"                                             
                                           
                                                                       
                                           
                                                                       
                                           




you need to look at the FORM collection :

document.<form name>.

check out the following URLs :

http://www.sharkysoft.com/tutorials/jsa/content/023.html
http://www.google.com/search?hl=3Den&lr=3D&ie=3DISO-8859-1&q
=3D%22javascript+radio+buttons%22

If you need more please post some code or a URL.

At 00:00 06/08/02 +0000, you wrote:

>Cool,
>
>But see that=B4s the problem, I=B4m beggining with JavaScript, so I'm 
not
>really sure what values I have to read. I think the document.location 
is
>no problem, but how do I read which radio button and pass its value to
 the
>document.location
>
>Thanx
>
>
> > read the values and then do a document.location depending on the va
lue
>of=3D20
>the one selected.
>
>At 23:31 05/08/02 +0000, you wrote:
>
> >Hi,
> >
> >I=3DB4d like to have a form that takes me to one of three different 
URL's.
> >I'd like to do it with radio buttons, so depending which one is the
active
> >one, after clicking on the submit button it takes me to the URL that
 was
> >previously selected in the radio buttons.
> >
> >How can I do it with javaScript?
> >
> >
> >Any help will be greatly appreciated.
> >
> >
> >Thank you.
> >
> >Oma Esquivel.
> >
> >---
> >
> >Improve your web design skills with these new books from Glasshaus.
> >
> >Usable Web Menus
>
>http://www.amazon.com/exec/obidos/ASIN/1904151027/ref=3D3Dnosim/thepro
gramme
> >r-20
> >Constructing Accessible Web Sites
>
>http://www.amazon.com/exec/obidos/ASIN/1904151000/ref=3D3Dnosim/thepro
gramme
> >r-20
> >Practical JavaScript for the Usable Web
>
>http://www.amazon.com/exec/obidos/ASIN/1904151051/ref=3D3Dnosim/thepro
gramme
> >r-20
> >to unsubscribe send a blank email to=3D20
>
>
>
>---
>
>Improve your web design skills with these new books from Glasshaus.
>
>Usable Web Menus
>http://www.amazon.com/exec/obidos/ASIN/1904151027/ref=3Dnosim/theprogr
amme
>r-20
>Constructing Accessible Web Sites
>http://www.amazon.com/exec/obidos/ASIN/1904151000/ref=3Dnosim/theprogr
amme
>r-20
>Practical JavaScript for the Usable Web
>http://www.amazon.com/exec/obidos/ASIN/1904151051/ref=3Dnosim/theprogr
amme
>r-20




---

Improve your web design skills with these new books from Glasshaus.

Usable Web Menus
http://www.amazon.com/exec/obidos/ASIN/1904151027/ref=3Dnosim/theprogra
mme
r-20
Constructing Accessible Web Sites
http://www.amazon.com/exec/obidos/ASIN/1904151000/ref=3Dnosim/theprogra
mme
r-20
Practical JavaScript for the Usable Web
http://www.amazon.com/exec/obidos/ASIN/1904151051/ref=3Dnosim/theprogra
mme
r-20





  Return to Index