Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7
  1. #1
    New Coder
    Join Date
    Aug 2005
    Location
    Canberra, ACT
    Posts
    16
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Javascript Radio Button value retrieval question

    Hi guys - I am working on a menu using radio buttons on the left handed side of a frameset, and I cannot get it to work. Any help or advice would be muchly appreciated - I am going mad!!!

    Regards,

    Justin


    <html>
    <head>

    <script type="text/javascript">
    function go()
    {
    var goto="none";
    if (document.nav.link[0].checked)
    goto=nav.link[0].value;
    if (document.nav.link[1].checked)
    goto=nav.link[1].value;
    if (document.nav.link[2].checked)
    goto=nav.link[2].value;

    parent.rightframe.location=document.getElementById(goto).value;
    }
    </script>

    </head>
    <body>

    <form name="nav" id="nav">
    <input type="radio" name="link" value="cit.html"/>CIT<br />
    <input type="radio" name="link" value="currency.html"/>Currency<br />
    <input type="radio" name="link" value="survey.html"/>Staff Survey<br />
    <input type="radio" name="link" value="game.html"/>Game<br /><br />
    </form>


    <input type="button" value="Go" onClick="go();"/>

    </body>
    </html>

  • #2
    Senior Coder
    Join Date
    Mar 2005
    Location
    Portsmouth UK
    Posts
    4,516
    Thanks
    3
    Thanked 505 Times in 492 Posts
    change

    parent.rightframe.location=document.getElementById(goto).value;

    to

    parent.rightframe.href=document.getElementById(goto).value;

    till I have time to look at this properly

  • #3
    Senior Coder
    Join Date
    Aug 2002
    Location
    UK
    Posts
    2,789
    Thanks
    2
    Thanked 14 Times in 14 Posts
    Change

    parent.rightframe.location=document.getElementById(goto).value;


    to

    parent.rightframe.location=goto

    I would also change the words go and goto because they may be reserved words
    The silent one.

    The most dangerous thing in the world is an idea.
    The most dangerous person in the world is the one with an idea.

  • #4
    Master Coder felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    6,642
    Thanks
    0
    Thanked 649 Times in 639 Posts
    goto is a reserved word so you can't use it.

    go is not reserved but has special meanings that will not be available if you use it as a field name.
    Stephen
    Learn Modern JavaScript - http://javascriptexample.net/
    Helping others to solve their computer problem at http://www.felgall.com/

    Don't forget to start your JavaScript code with "use strict"; which makes it easier to find errors in your code.

  • #5
    New Coder
    Join Date
    Aug 2005
    Location
    Canberra, ACT
    Posts
    16
    Thanks
    0
    Thanked 0 Times in 0 Posts
    thank you all very much for your help, I appreciate it. I now have the problem licked.

  • #6
    New Coder
    Join Date
    Jun 2008
    Posts
    15
    Thanks
    1
    Thanked 0 Times in 0 Posts
    i need help with the same thing..
    i changed his code..
    but its not working..

    any help?

  • #7
    Senior Coder
    Join Date
    Aug 2002
    Location
    UK
    Posts
    2,789
    Thanks
    2
    Thanked 14 Times in 14 Posts
    If you post your code we may be able to help
    The silent one.

    The most dangerous thing in the world is an idea.
    The most dangerous person in the world is the one with an idea.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •