By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
439,993 Members | 1,947 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 439,993 IT Pros & Developers. It's quick & easy.

Drop down Lists

P: n/a
Hi,

I have the requirement of autoupdating the drop down lists , when a
selectin is done in another drop down box. I dont have a server through
which i can make it dynamic. I have to hard code it in the html. Can
someone suggest anything.

Prof

Jan 5 '07 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Prof wrote:
I have the requirement of autoupdating the drop down lists , when a
selectin is done in another drop down box. I dont have a server through
which i can make it dynamic. I have to hard code it in the html. Can
someone suggest anything.
<form>
I'm looking for:
<select name="sel1" size="1"
onChange="pop2(this.options[this.selectedIndex].value)">
<option value="">-</option>
<option value="cars">cars</option>
<option value="accommodation">accommodation</option>
</select>
<br>
Further selection:
<select name="sel2" size="1">
<option value="">-</option>
</select>
<select name="sel3" size="1">
<option value="">-</option>
</select>
</form>
<script type="text/javascript">
var cars = new Array('Audi', 'BMW', 'Opel');
var car_colors = new Array('white', 'metallic', 'black');
var acc = new Array('Brussels', 'Antwerp', 'Ghent')
var acc_types = new Array('studio', 'house', 'villa');
var hyphen = new Array('-');
var S2 = document.forms[0].sel2;
var S3 = document.forms[0].sel3;

function pop2(c) {
while (S2.options.length) S2.options[0] = null;
while (S3.options.length) S3.options[0] = null;
if (c == '') { fill(hyphen, S2); fill(hyphen, S3) }
if (c == 'cars') { fill(cars, S2); fill(car_colors, S3) }
if (c == 'accommodation') { fill(acc, S2); fill(acc_types, S3) }
}

function fill(arr, el) {
for (var i = 0; i < arr.length; i++)
el.options[el.length] = new Option(arr[i], arr[i]);
}
</script>

Hope this helps,

--
Bart

Jan 5 '07 #2

P: n/a

Prof wrote:
Hi,

I have the requirement of autoupdating the drop down lists , when a
selectin is done in another drop down box. I dont have a server through
which i can make it dynamic. I have to hard code it in the html. Can
someone suggest anything.

Prof
hi, have you ever heard about ajax, you can update drop down list
automatically,

Jan 5 '07 #3

P: n/a
Prof wrote:
I have the requirement of autoupdating the drop down lists , when a
selectin is done in another drop down box. I dont have a server
through which i can make it dynamic. I have to hard code it in the
html. Can someone suggest anything.
http://www.JavascriptToolbox.com/lib/dynamicoptionlist/

--
Matt Kruse
http://www.JavascriptToolbox.com
http://www.AjaxToolbox.com
Jan 5 '07 #4

P: n/a
Thanks bart that was really helpfull.

Jan 11 '07 #5

This discussion thread is closed

Replies have been disabled for this discussion.