www.webdeveloper.com
Results 1 to 4 of 4

Thread: [RESOLVED] Need help: Using form validation to open target

  1. #1
    Join Date
    May 2008
    Location
    San Jose, CA
    Posts
    3

    resolved [RESOLVED] Need help: Using form validation to open target

    I have three radio buttons in a form (along with a lot of other information) when the user submits the form I want to open a new html page based on which of the radio buttons was checked. Any help would be greatly appreciated.

  2. #2
    Join Date
    May 2008
    Location
    San Jose, CA
    Posts
    3
    I should say to that I am using this to build a mock of what a desired application will do so I do not care what happens to rest of the data in the form.

  3. #3
    Join Date
    Apr 2003
    Location
    Netherlands
    Posts
    21,654
    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
    <html lang="en">
    <head>
    <title>redirect</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    
    <script type="text/javascript">
    function newDoc(f) {
    for(var i=0; i<f.address.length; i++) {
        if(f.address[i].checked) {
            location.href='http://www.'+f.address[i].value+'/';
            break;
            }
        }
    return false;
    }
    </script>
    
    <style type="text/css">
    label {display:block;} 
    </style>
    
    </head>
    <body>
    <form action="#" method="" name="form1" onsubmit="return newDoc(this);">
    <div>
        <label>google<input name="address" type="radio" value="google.com"></label>
        <label>msn<input name="address" type="radio" value="msn.com"></label>
        <label>webdeveloper<input name="address" type="radio" value="webdeveloper.com"></label>
    <button type="submit">submit</button>
    </div>
    </form>
    </body>
    </html>
    At least 98% of internet users' DNA is identical to that of chimpanzees

  4. #4
    Join Date
    May 2008
    Location
    San Jose, CA
    Posts
    3
    That is terrific. I was totally going in the wrong direction. Thank you.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles