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
    Sep 2003
    Posts
    40
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Help With Linking Forms

    have this form-type link which looks like this:


    <div style="filter: alpha (opacity=65, style=0);">
    <br><br>
    <div class="links">
    <form name="jump">
    <select style="border:3px solid #000000; font-size: 8pt; color: #666666; font-family: verdana; word-spacing: 0; text-align: center; line-height: 100%; text-indent: 0; margin: 0; padding: 0; background: #000000" onchange="self.location=this.options[this.selectedIndex].value" name="select">
    <option selected>link</option>
    <option value="http://www.home.com">home</option>
    <option value="http://www.com">link</option>
    <option value="http://www.com">link</option>
    <option value="http://www.com">link</option>
    <option value="http://www.com">link</option>
    </select>
    </form>


    Is there anything i could do to make the "home" link stay in my iFrame and the "link" links open in a new window? As in if i select the option "home" i would be nevigated back home inside my iFrame while if i select one of my friends links which is "link", it would pop up in a new window.

    Is there anything i could do keeping the same form-type?

    Thanks!

    -Jolin

  • #2
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,075
    Thanks
    0
    Thanked 256 Times in 252 Posts
    Code:
    function go(sel){
      var index = sel.selectedIndex;
      if (sel.options[index].value!='') {
        if (index == 1) location.href = sel.options[index].value; //home
        else window.open(sel.options[index].value); //other links
      } 
    }
    ...
    <select onchange="go(this)">
    Last edited by glenngv; 10-21-2003 at 12:51 PM.
    Glenn
    ____________________________________

    My Blog
    Tower of Hanoi Android app (FREE!)
    Tower of Hanoi Leaderboard
    Samegame Facebook App
    vBulletin Plugins
    ____________________________________

  • #3
    New Coder
    Join Date
    Sep 2003
    Posts
    40
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks glenngv for coming to my aid.

    However, where do i insert this javascript, after my form code?

    Or if this javascript is inclusive of the form code, where do i add my hyperlinks in the code?

    Thanks!

    -Jolin

  • #4
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,075
    Thanks
    0
    Thanked 256 Times in 252 Posts
    put the script inside the <head> tag
    then in the form:
    <form>
    <select onchange="go(this)">
    <option selected>--Select one--</option>
    <option value="http://www.mydomain.com/home.htm">Home</option>
    <option value="http://www.yahoo.com">Yahoo</option>
    <option value="http://www.codingforums.com">CodingForums</option>
    <option value="http://www.microsoft.com">Microsoft</option>
    <option value="http://www.hotmail.com">Hotmail</option>
    </select>
    </form>
    Glenn
    ____________________________________

    My Blog
    Tower of Hanoi Android app (FREE!)
    Tower of Hanoi Leaderboard
    Samegame Facebook App
    vBulletin Plugins
    ____________________________________

  • #5
    New Coder
    Join Date
    Sep 2003
    Posts
    40
    Thanks
    0
    Thanked 0 Times in 0 Posts
    it doesnt work

    my <head> looks something like this:

    <html>
    <head>
    <title>title</title>
    <style><!--body{cursor:crosshair}--></style>
    <style>

    function go(sel){
    var index = sel.selectedIndex;
    if (sel.options[index].value!='') {
    if (index == 1) location.href = sel.options[index].value; //home
    else window.open(sel.options[index].value); //other links
    }
    }
    ...
    <select onchange="go(this)">

    </head>


    My <body> where my form is looks something like this:


    <div style="width: 30px;position: absolute; top: -225px; left: 360px;">
    <div style="filter: alpha (opacity=65, style=0);">
    <br><br>
    <div class="links">
    <form name="jump">
    <select style="border:3px solid #000000; font-size: 8pt; color: #666666; font-family: verdana; word-spacing: 0; text-align: center; line-height: 100%; text-indent: 0; margin: 0; padding: 0; background: #000000" onchange="self.location=this.options[this.selectedIndex].value" name="select">
    <select onchange="go(this)">
    <option selected>LINKS</option>
    <option value="http://www.home.com">home</option>
    <option value="http://friend.com">friend1</option>
    <option value="http://friend.com">friend2</option>
    <option value="http://friend.com">friend3</option>
    <option value="http://friend.com">friend4</option>
    </select>
    </form>


    Please correct me if there is any mistakes with this. Thanks again for your help. I really appreciated it.

    -Jolin

  • #6
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,075
    Thanks
    0
    Thanked 256 Times in 252 Posts
    I thought you already know HTML and javascript. You should put the javascript codes in the <script> tag.

    <html>
    <head>
    <title>title</title>
    <style><!--body{cursor:crosshair}--></style>
    <script type="text/javascript">

    function go(sel){
    var index = sel.selectedIndex;
    if (sel.options[index].value!='') {
    if (index == 1) location.href = sel.options[index].value; //home
    else window.open(sel.options[index].value); //other links
    }
    }
    </script>
    </head>
    <body>
    <div style="width: 30px;position: absolute; top: -225px; left: 360px;">
    <div style="filter: alpha (opacity=65, style=0);">
    <br><br>
    <div class="links">
    <form name="jump">
    <select style="border:3px solid #000000; font-size: 8pt; color: #666666; font-family: verdana; word-spacing: 0; text-align: center; line-height: 100%; text-indent: 0; margin: 0; padding: 0; background: #000000" onchange="go(this)" name="select">
    <option selected>LINKS</option>
    <option value="http://www.home.com">home</option>
    <option value="http://friend.com">friend1</option>
    <option value="http://friend.com">friend2</option>
    <option value="http://friend.com">friend3</option>
    <option value="http://friend.com">friend4</option>
    </select>
    </form>
    </body>
    </html>
    Glenn
    ____________________________________

    My Blog
    Tower of Hanoi Android app (FREE!)
    Tower of Hanoi Leaderboard
    Samegame Facebook App
    vBulletin Plugins
    ____________________________________

  • #7
    New Coder
    Join Date
    Sep 2003
    Posts
    40
    Thanks
    0
    Thanked 0 Times in 0 Posts
    oh hehe. totally forgotten about that

    Thanks Glenn!!!


  •  

    Posting Permissions

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