Discover Habbo's history
Treat yourself with a Secret Santa gift.... of a random Wiki page for you to start exploring Habbo's history!
Happy holidays!
Celebrate with us at Habbox on the hotel, on our Forum and right here!
Join Habbox!
One of us! One of us! Click here to see the roles you could take as part of the Habbox community!


Results 1 to 3 of 3
  1. #1
    Join Date
    Apr 2006
    Location
    Leamington Spa
    Posts
    1,375
    Tokens
    72

    Latest Awards:

    Default JavaScript - HELP?

    Right well, what I want is like a thing where they select the site from a drop down form box, and it takes them there.
    Here's my code:
    HTML Code:
    <html><head>
    <script type="javascript">
    var to = "";
    function goTo(to)
    {
    window.location=to;
    }
    </script>
    </head>
    <body>
    Where would you like to go today?: <select>
    <option onClick="goTo('http://google.co.uk');">Google UK</option>
    <option onClick="goTo('http://google.fr');">Google France</option>
    </select>
    </body>
    </html>
    Any help appreciated.

    EDIT: Nevermind, I've got it.

    Moved by Agesilaus (Forum Moderator) from Design & Development: Please post in the correct forum next time.
    Last edited by Agesilaus; 30-12-2007 at 05:28 AM.
    i've been here for over 8 years and i don't know why

  2. #2
    Join Date
    Dec 2007
    Posts
    412
    Tokens
    0

    Default

    HTML Code:
    <form name="form1" id="form1">
      <select name="menu1" onchange="MM_jumpMenu('parent',this,0)">
        <option value="#">Text in here</option>
        <option value="#">Text in here</option>
        <option value="#">Text in here</option>
      </select>
      <input type="button" name="Button1" value="Go" onclick="MM_jumpMenuGo('menu1','parent',0)" />
    </form>
    HTML Code:
    <script type="text/JavaScript">
    <!--
    function MM_jumpMenu(targ,selObj,restore){ //v3.0
      eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
      if (restore) selObj.selectedIndex=0;
    }
    
    function MM_findObj(n, d) { //v4.01
      var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
        d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
      if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
      for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
      if(!x && d.getElementById) x=d.getElementById(n); return x;
    }
    
    function MM_jumpMenuGo(selName,targ,restore){ //v3.0
      var selObj = MM_findObj(selName); if (selObj) MM_jumpMenu(targ,selObj,restore);
    }
    //-->
    </script>
    Is another way to do it, even though it's longer and messier. :p

  3. #3
    Join Date
    May 2006
    Posts
    1,797
    Tokens
    0

    Latest Awards:

    Default

    Doesnt dreamweaver produce the above code :S?
    Coming and going...
    Highers are getting the better of me

Posting Permissions

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