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 4 of 4
  1. #1
    New Coder
    Join Date
    Jun 2008
    Posts
    15
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Radio button to link on SUBMIT

    ok i have 5 radio buttons

    [ ] Link
    [ ] Link
    [x] Link
    [ ] Link
    [ ] Link


    [ SUBMIT ]


    I want that when i click SUBMIT, to go to the 3rd link.


    I've been looking all over the net, but I dunno if what i typed in was wrong or something.

  • #2
    Regular Coder BoldUlysses's Avatar
    Join Date
    Jan 2008
    Location
    Winston-Salem, NC
    Posts
    938
    Thanks
    10
    Thanked 190 Times in 187 Posts
    I'm sure there's a much more elegant way to do it, but here's a little PHP script:

    PHP Code:
    <?php
        
    if (!isset($_POST['submit'])) {
    ?>

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
    <title>Radio Link Page</title>

    </head>

    <body>

    <h3>Radio Link Page</h3>

    <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
     <p><input type="radio" name="link" value="link1"/>Link 1</p>
     <p><input type="radio" name="link" value="link2"/>Link 2</p>
     <p><input type="radio" name="link" value="link3"/>Link 3</p>
     <p><input type="radio" name="link" value="link4"/>Link 4</p>
     <p><input type="submit" name="submit" value="Select"/></p>
    </form>

    </body>
    </html>
        
    <?php 
        
    }
        else {
            
    $linkName $_POST["link"].".html";
            
    header("Location: /$linkName");
        }
    ?>
    matt | design | blog

  • Users who have thanked BoldUlysses for this post:

    nickbunyun (07-25-2008)

  • #3
    Senior Coder rangana's Avatar
    Join Date
    Feb 2008
    Location
    Cebu City, Philippines
    Posts
    1,752
    Thanks
    65
    Thanked 372 Times in 365 Posts
    JS:
    Code:
    <script type="text/javascript">
    window.onload=function(){
    var df=document.forms[0];
    df.onsubmit=function()
    {df[2].checked=true;return false;}}
    </script>
    <form>
    <p><input type="radio">Link 1</p>
    <p><input type="radio">Link 2</p>
    <p><input type="radio">Link 3</p>
    <p><input type="radio">Link 4</p>
    <p><input type="submit"></p>
    </form>
    Learn how to javascript at 02geek

    The more you learn, the more you'll realize there's much more to learn
    Ray.ph

  • #4
    New Coder
    Join Date
    Jun 2008
    Posts
    15
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by msuffern View Post
    I'm sure there's a much more elegant way to do it, but here's a little PHP script:

    PHP Code:
    <?php
        
    if (!isset($_POST['submit'])) {
    ?>

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
    <title>Radio Link Page</title>

    </head>

    <body>

    <h3>Radio Link Page</h3>

    <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
     <p><input type="radio" name="link" value="link1"/>Link 1</p>
     <p><input type="radio" name="link" value="link2"/>Link 2</p>
     <p><input type="radio" name="link" value="link3"/>Link 3</p>
     <p><input type="radio" name="link" value="link4"/>Link 4</p>
     <p><input type="submit" name="submit" value="Select"/></p>
    </form>

    </body>
    </html>
        
    <?php 
        
    }
        else {
            
    $linkName $_POST["link"].".html";
            
    header("Location: /$linkName");
        }
    ?>
    *whispers* ily!

    lol, thanks man!
    worked perfect with what I need.


  •  

    Posting Permissions

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