Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

a dropdown menu question

Status
Not open for further replies.

OhioSteve

MIS
Mar 12, 2002
1,352
US
This dropdown menu sets a value and the button sends
you to fruits.asp. Certain things occur in Fruits.asp
based upon the option value.

<form method=&quot;POST&quot; action=&quot;fruits.asp&quot;>
<p align=&quot;left&quot;>
<select name=&quot;AccessType&quot;>
<option value=&quot;A&quot; selected> apple </option>
<option value=&quot;G&quot;>grape</option>
<option value=&quot;C&quot;>cherry</option>
</select>
<input type=&quot;submit&quot; value=&quot;GO&quot; name=&quot;Submit&quot; tabindex=&quot;2&quot;></p>
</form>

I want to increase the number of choices. In addition,
I want the new choices to APPEAR in a submenu on the right.
For example, if the user touches &quot;grape&quot; I might want a
submenu to appear with captions like &quot;seedless&quot; and
&quot;traditional&quot;. However, I do not need to set two
variables, just one. So it will appear to the user that
they are making two choices (ie fruit and type of fruit)
but really they are just setting one option value.

Any ideas?
 
This is a method I always use if the data is not going to change frequently, otherwise I post to the database and populate the child list:

<script language=&quot;javascript&quot; src=&quot;jscripts/_make_businessdropdowns.js&quot;></script>
<script language=&quot;javascript&quot;>
function set_business_function(ranges, values) {
selectedIndex = 0;
var dropDown;
dropDown = document.f.businessfunction;
if (dropDown) {
dropDown.length = 0;
for(index=0; index<ranges.length; index++) {
dropDown[index] = new Option(ranges[index],values[index], false, false);
}
dropDown.options[selectedIndex].selected = true;
}
}
</script>

HTML:

<select name='busunit' onChange=&quot;set_business_function(_business_unit_function[this.selectedIndex], _business_unit_function_number[this.selectedIndex]);&quot; >
<option value=&quot;1000&quot;>All or Select A Business Unit</option>
<option value=&quot;0&quot;>Retail Wide News</option>
<option value=&quot;1&quot;>Alternative Channels</option>
<option value=&quot;2&quot;>World</option>
<option value=&quot;3&quot;>Regions</option>
<option value=&quot;4&quot;>Business</option>
<option value=&quot;5&quot;>Business Improvement</option>
<option value=&quot;6&quot;>Consumer</option>
<option value=&quot;7&quot;>Customer Contact Centre</option>
<option value=&quot;8&quot;>Field Service</option>
<option value=&quot;9&quot;>Finance & Business Management</option>
<option value=&quot;10&quot;>Human Resources & Management Services</option>
<option value=&quot;11&quot;>Internet Operations</option>
<option value=&quot;12&quot;>Major Business</option>
<option value=&quot;13&quot;>Products & Enterprises</option>
<option value=&quot;14&quot;>Transformation Technology</option>
</select>


js file:


_business_unit_function = new Array();
_business_unit_function_number = new Array();

// defautl menu structure
_business_unit_function[0] = new Array('All or Select A Business Unit Community','');
_business_unit_function_number[0] = new Array(1000,1000);

_business_unit_function[1] = new Array('All or Select A Business Unit Community','Retail Wide News');
_business_unit_function_number[1] = new Array(1000,1000);

_business_unit_function[2] = new Array('All or Select A Business Unit Community','Indirect Channels');
_business_unit_function_number[2] = new Array(1000,1);

_business_unit_function[3] = new Array('All or Select A Business Unit Community','World');
_business_unit_function_number[3] = new Array(1000,1000);

_business_unit_function[4] = new Array('All or Select A Business Unit Community','Northern Ireland','Scotland','North East Region','North West Region','Yorkshire & Humberside Region','West Midlands Region','East Midlands Region','East of England Region','London','South East Region','South West Region','Wales');
_business_unit_function_number[4] = new Array(1000,2,3,4,5,6,7,8,9,10,11,12,13);

_business_unit_function[5] = new Array('All or Select A Business Unit Community','Alternative Channels','Campaigns','Corporate Sales','Customer Satisfaction','Enterprise Sales','Enterprise Sales - Desks','Enterprise Sales - Field','Enterprise Sales - Islands','Marketing')
_business_unit_function_number[5] = new Array(1000,14,15,16,17,18,19,20,21,22)

_business_unit_function[6] = new Array('All or Select A Business Unit Community','Business Improvement');
_business_unit_function_number[6] = new Array(1000,1000);

_business_unit_function[7] = new Array('All or Select A Business Unit Community','Payphones');
_business_unit_function_number[7] = new Array(1000,23);

_business_unit_function[8] = new Array('All or Select A Business Unit Community','Customer Contact Centre');
_business_unit_function_number[8] = new Array(1000,1000);

_business_unit_function[9] = new Array('All or Select A Business Unit Community','Field Service');
_business_unit_function_number[9] = new Array(1000,1000);

_business_unit_function[10] = new Array('All or Select A Business Unit Community','Alternative Channels Finance','Regions Finance','Business Finance','Consumer Finance','Customer Service Finance & Billing','Finance Major Business','Finance Planning & Reporting','Finance Venturing & Solutions','Legal & Regularity','Products & Enterprises Finance','Retail Commercial','Retail Strategy');
_business_unit_function_number[10] = new Array(1000,24,25,26,27,28,29,30,31,32,33,34,35);

_business_unit_function[11] = new Array('All or Select A Business Unit Community','Human Resources & Management Services');
_business_unit_function_number[11] = new Array(1000,1000);

_business_unit_function[12] = new Array('All or Select A Business Unit Community','Internet Operations');
_business_unit_function_number[12] = new Array(1000,1000);

_business_unit_function[13] = new Array('All or Select A Business Unit Community','Major Business');
_business_unit_function_number[13] = new Array(1000,1000);

_business_unit_function[14] = new Array('All or Select A Business Unit Community','Conferencing','Mobility','CTO','IT Portfolio','Network Products','Network Products - Message Services','Open Orchard','Redcare','Strategic Partnerships');
_business_unit_function_number[14] = new Array(1000,35,36,37,38,39,40,41,42,43);

_business_unit_function[15] = new Array('All or Select A Business Unit Community','Transformation and Technology');
_business_unit_function_number[15] = new Array(1000,1000);


















 
The form method does not have anything built in to make a dropdown menu with a submenu?
 
sorry steve missed a bit:

<select name=&quot;businessfunction&quot;>
<option value=&quot;1000&quot;>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</option>
</select>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top