SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Enthusiast
    Join Date
    Feb 2003
    Location
    tio
    Posts
    28
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Selectbox problem

    I have a select box with four different options and I when I choose an option and click on a button i want it to go to a particular page.For example when I choose 'Cars' and click on the button I want it to go to a page called cars.html ,When I choose 'Bikes' and click on the button i want it to go to a page called bikes.html.
    Can anybody here help me with this?

  2. #2
    ********* Wizard silver trophy Cam's Avatar
    Join Date
    Aug 2002
    Location
    Burpengary, Australia
    Posts
    4,495
    Mentioned
    0 Post(s)
    Tagged
    1 Thread(s)
    Here is the JS function you will need
    Code:
    function openPage(objSelect) 
    {
     other = 'directories=no,height=400,width=450,location=no,menubar=no,resizable=no,scrollbars=yes,status=no,toolbar=no,top=200,left=150';
     o = window.open(objSelect[objSelect.selectedIndex].value,'secondwindow',other,false);
     o.focus();
     return o;
    }
    and here's how to use it
    Code:
    	<select name='config' onchange='openPage(this)'>
    	<option value='cars.html' selected='selected'>Cars</option>
    	<option value='bikes.html'>Bikes</option>
    	</select>

  3. #3
    SitePoint Enthusiast
    Join Date
    May 2001
    Location
    London
    Posts
    40
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Try this: Paste the script bit in the top of your page and then the <form...> bit in the place where you want your selection box to go. Change the option value to your site and structure etc. If you change the name of the form, don't forget to change it in the script (in the href=document.myform.options bit).

    <SCRIPT language="JavaScript">
    <!--
    function gothere()
    {
    PopUpName=window.open('','PopUpName');PopUpName.location.href=document.myform.menu.options[document.myform.menu.selectedIndex].value;
    }
    //-->
    </SCRIPT>


    <form name="myform">
    <select name="menu">
    <option value="http://www.yoursite.co.uk/cars.htm">Cars</option>
    <option value="http://www.yoursite.co.uk/bikes.htm">Bikes</option>
    </select>
    <A HREF="#" onclick="gothere();return false;">


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
  •