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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

State > City > location (3) listboxes cascading/updating

Status
Not open for further replies.

Dijital

MIS
Mar 15, 2002
47
US
I'm trying to figure out how to create three cascading listboxes that update one another.

List box 1 = State (onchange, should update list box 2)
list box 2 = City (onchange, should update list box 3)
List box 3 = Location

My company has retail locations (~11,000) around the US. The goal here is to record Network and system outages, and assign impact per location.

I just dont want to hard code 11,000 locations to choose from.

I saw a javascript version of this, but I know more Japanese than Java...

I'd prefer not to make multiple trips to the server between listbox selections. Is it possible to use an include with the locational information? or on the page load have a single recordset like "Select State, City, Location from location_lkup" or is that just going to be an ugly amount of data?

Help would be greatly appreciated!!!

Jim Connors
 
You need 3 things

1. jscript to create child menu

<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>

2. event generator to trigger creation of child menu

<select name='busunit' onChange=&quot;set_business_function(_business_unit_function[this.selectedIndex], _business_unit_function_number[this.selectedIndex]);&quot; >


3. js file that you include ( jscripts/_make_businessdropdowns.js) with your data for your child menus


_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',' Openworld');
_business_unit_function_number[2] = new Array(1000,1000);

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

_business_unit_function[4] = new Array('All or Select A Business Unit Community','Local Business','Corporate Sales','Customer Satisfaction','Enterprise Sales','Enterprise Sales, Desks','Enterprise Sales, Field','Enterprise Sales, Islands','Indirect Channels','Marketing','Operational Effectiveness','Service Provider Group');
_business_unit_function_number[4] = new Array(1000,2,3,4,5,6,7,8,9,10,11,45);

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

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

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

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

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

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

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

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

_business_unit_function[13] = new Array('All or Select A Business Unit Community','Conferencing','Mobile','Network Products','Network Products, Communication Products','Wireless Broadband','redcare','ICT & Strategic Partnerships');
_business_unit_function_number[13] = new Array(1000,13,14,15,16,17,18,19);

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


HHope this helps a little

 
I want to start off by saying THANK YOU MIT99!!!

Now for the sheepish apology, but amidst my third all nighter, I neglected to point out that I was looking for a VBSCript example to use. *oops!*

Thank you very much Mitt99, hopefully someone can use that example - it is quite complete.

If anyone knows a VBScript version of this, I'd appreciate it!!

Jim (better rested now!)

 
Mit99,

So I've given up on finding a vbscript version, and have decided to give your example a try.

I have taken the code and plugged it in accordingly.
I was left with a blank pulldown that did nothing - so I'm guessing I'm missing something.
I placed options in the select group like so:

<select name='busunit' onChange=&quot;set_business_function(_business_unit_function[this.selectedIndex], _business_unit_function_number[this.selectedIndex]);&quot; >
<option value=&quot;0&quot;>0</option>
<option value=&quot;1&quot;>1</option>
<option value=&quot;2&quot;>2</option>
<option value=&quot;3&quot;>3</option>
</select>

When I select an option I get an error that says:

'document.f.businessfunction' is null or not an object.

I dont see a reference to this anywhere in the code save the function at the top of the page. Was I supposed to add a bit of something that I missed?

Jim
 
You need a menu that will be dynamically populated called businessfunction or whatever you call it - change the name in the set_business_function function
 
There are a couple FAQs that you may want to check out that cover this subject area in detail.

-T

[sub]01000111 01101111 01110100 00100000 01000011 01101111 01100110 01100110 01100101 01100101 00111111[/sub]
The never-completed website:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top