Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 2 of 2

Thread: Dropdown Menu

  1. #1
    Junior Member
    Join Date
    Oct 2010
    Posts
    11
    Member #
    24384
    Hi,
    I have a menu that lets me select from multiple options, and I want that any option that I choose will lead me to another website, after that I click the submit button.
    How I do this?

    Code:
    <form action="" method="post">
    
    <select name="Dropdown Menu" id="menu">
    <option selected>Select</option>
    <option value="1">1</option>
    <option value="2">2</option>
    <option value="3">3</option>
    </select>
    
    <input type="submit" value="" id="button">
    </form>
    Thanks,
    Steve

  2.  

  3. #2
    Member JayWood's Avatar
    Join Date
    Oct 2010
    Location
    East Coast U.S.
    Posts
    55
    Member #
    24240
    I had to do something like this for a customer a few months ago, it's quite simple really. You need the jQuery library for this, you can do it in plain javascript but good luck Anyhow, setup your options like so:

    HTML Code:
            <select id="specInt">
                    <option value="#" selected="selected">--- Select One ---</option>  
                    <option value="wii">Nintendo Wii</option> 
                    <option value="yoga">Yoga</option> 
            </select>
    Once you've done that set the javascript directly under it like so:
    HTML Code:
    		<script type="text/javascript"> 
    				$("#specInt").change(function(){
    					var opVal = $(this).val();
    					document.location.href="/"+opVal;
    				});
                </script>
    The script will take a user to the "value" of the option when they select it, without the use of a "submit" button. If you want a full URL, just change the option values to the urls you want instead of directories, and change the (document.location.href="/"+opVal by removing the ("/"+) from the line, therefore directing the user to the EXACT option value.
    Don't forget to Rep people if they've helped you, it's just the right thing to do.
    My Site - JJ's Webs
    My oDesk Profile - Hire me on oDesk
    My Themeforest Profile - Just for you TF people!


Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 06:03 AM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com