SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Member
    Join Date
    Sep 2007
    Posts
    6
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    How Do I Create This Effect

    Hi everyone I am hoping some can help me I am pretty new to all this.

    I want to create a form using radio button and a submit button for user to click when they selected they choice form the radio buttons.

    When radio button one is selected submit button pressed it should go to http:webpageofmychoice1.com

    When radio button two is selected submit button pressed it should go to http:webpageofmychoice2.com

    When radio button three is selected submit button pressed it should go to http:webpageofmychoice3.com

    I have tried a java script but I can only seem to get it work with only one option not more then one can anyone please help thanks.

  2. #2
    SitePoint Evangelist bals28mjk's Avatar
    Join Date
    Aug 2007
    Posts
    405
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Maybe something like:
    Code:
    <html>
    <head>
    <script type="text/javascript">
    function func()
    {
    	el=document.getElementsByName("r")
    	for(var i=0; el.length>i; i++)
    	{
    		if(el[i].checked==true){ break; }
    	}
    	location.href=el[i].value
    }
    </script>
    </head>
    <body>
    <form>
    <input name="r" type="radio" value="http://www.sitepoint.com/forums/showthread.php?t=505161" checked />Sitepoint<br />
    <input name="r" type="radio" name="r" value="http://www.yahoo.com" />Yahoo<br />
    <input name="r" type="radio" name="r" value="http://www.google.com" />Google<br /><br />
    <input type="button" onclick="func()" value="Go!" />
    </form>
    </body>
    </html>

  3. #3
    SitePoint Member
    Join Date
    Sep 2007
    Posts
    6
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks so much bals28mjk this is exactly what I wanted the only difference I that I wanted to use a image submit button but that was no issue I was able to edit that one line and use a image instead. Thanks a million for you help. I am new here and I am really glad I joined you guys are very helpful

  4. #4
    SitePoint Evangelist bals28mjk's Avatar
    Join Date
    Aug 2007
    Posts
    405
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Welcome to sitepoint iaffiliate . I agree, everyone who helped in this thread is very awesome and smart.

  5. #5
    doRighteousDeeds++
    Join Date
    Aug 2006
    Location
    تركيا Turkey Türkiye
    Posts
    266
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Code:
      
    <html>
    <head>
    <script type="text/javascript">
    var iaffiliate = {
    go : function (myid) {
    location.href = el(myid).value;
    function el (elid) { return document.getElementById(elid); }
    }
    }
    </script>
    </head>
    <body>
    <form>
    <input name="r" type="radio" id="r0" value="http://www.sitepoint.com/forums/showthread.php?t=505161" onclick="iaffiliate.go('r0')" />Sitepoint<br />
    <input name="r" type="radio" id="r1" value="http://www.yahoo.com" onclick="iaffiliate.go('r1')" />Yahoo<br />
    <input name="r" type="radio" id="r2" value="http://www.google.com" onclick="iaffiliate.go('r2')" />Google<br /><br />
    </form>
    </body>
    </html>
    The Time Through Ages. In the Name of Allah, Most Gracious, Most Merciful.
    1. By the Time, 2. Verily Man is in loss,
    3. Except such as have Faith, and do righteous deeds, and (join together) in the mutual enjoining of Truth, and of Patience and Constancy.


Bookmarks

Posting Permissions

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