19 users online (0 members and 19 guests)  


  Results 1 to 4 of 4

Related

  1. Replies: 5
  2. validating the checkbox,list/menu..    Forum: Javascript Forum
    Replies: 8
  3. Creating a form with file submission    Forum: Website Scripts Forum
    Replies: 1
  4. Replies: 3
  5. Replies: 3
  1. #1
    makoy's Avatar
    New User

    Status
    Offline
    Join Date
    Feb 2005
    Posts
    2

    Question Help please: Creating a link in a form list/menu

    Hello! I would like to ask how to make a link on a form's list/menu. Suppose I have this code :

    <select name="select">
    <option>Downloadable Forms</option> <option>History</option>
    </select>

    How do I put a link on each of these items? If
    you guys have a better suggestion I would really like to see it. thanks in advance!

  2. #2
    dlongnecker's Avatar
    Tired Student...(Z_z)

    Status
    Offline
    Join Date
    Aug 2004
    Location
    Wichita, KS
    Posts
    86
    Here's a quick site with several combo box options and the code for them...

    http://www.pacosdrivers.com/wm/js.asp?cat=8

    You need to create your select box with an onChange call to a JS element... the JS element can either be outside the page or in the <HEAD> section of the page.

    Code:
    <select name="navigation" onChange="go()">
    <option value="">--- Navigation ---</option>
    <option value="default.html">Home</option>
    <option value="page1.html">Page 1</option>
    <option value="page2.html">Page 2</option>
    </select>
    For the Javascript, you want to take the value in your select box (named 'navigation') and read it into a variable, then redirect the window to that variable (the new "destination").

    Code:
    function go()
    {
    	box = document.forms[0].navigation;
    	destination = box.options[box.selectedIndex].value;
    	if (destination) location.href = destination;
    }
    Hope this helps!

    Regards,
    Last edited by dlongnecker; 02-04-2005 at 01:17 PM.

  3. #3
    makoy's Avatar
    New User

    Status
    Offline
    Join Date
    Feb 2005
    Posts
    2

    Thumbs up

    yes it helps a lot!!! thank you very much dlongnecker!

  4. #4
    normantang's Avatar
    New User

    Status
    Offline
    Join Date
    Jan 2008
    Posts
    1

    Re: Help please: Creating a link in a form list/menu

    That's all very well, but how do you do it with more than one list/menus? I've got three on the same page and I want the lists to link to other web pages.



Tags for this Thread