Results 1 to 3 of 3
Thread: Auto-Selecting a Drop-Down Menu
Dec 17, 2003, 17:22 #1
- Join Date
- Nov 2001
- Bloomington, IN
- 0 Post(s)
- 0 Thread(s)
Auto-Selecting a Drop-Down MenuHTML Code:
[color=black]<form action="" method="post" name="form1"> Here is a function I co-wrote that selects an option in a drop-down menu based on a value you pass from another page. Here I needed to have a company contact page that automatically selected a department, depending on which department page you were coming from. You have to add a value to the end of the link to the contact page, making it different for each department. FUNCTION:Code:
Here form1 is the name of your form and emailto is the name of your drop-down menu, or select menu.
[color=black]<a href="contact.html?dept=1">Contact Department 2</a>Then, when linking to your contact page, you add a number on the end of the link like this. Note that the dept= is not needed, all the script is doing is pulling the number off of the end of the URL. This script only looks for a one digit number, so you can't have more than 10 options (0-9).
The options in a select menu can be called with numeric values, starting with 0 for the first one and continuing from there. So the value I am using above actually causes the select menu to display the 2nd option.
I am not sure this is the best way to do this, but it is a nice way to avoid having to setup a database.
Hope this is usefull for someone.