Like this...
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js"></script>
</head>
<script type="text/javascript">
jQuery( function() {
SetOption1Option2(jQuery('#option1List'), jQuery('#option2List'));
SetOption1Option2(jQuery('#option3List'), jQuery('#option4List'));
})
function SetOption1Option2(option1, option2)
{
var optionsArray = ['---', 'A', 'B', 'C', 'D', 'E', 'F'];
jQuery.each(optionsArray, function(index, value) {
option1.append('<option value="' + value + '">' + value + '</option>');
})
PopulateOption2(option1, option2)
option1.change( function() {
PopulateOption2(jQuery(this), option2)
});
}
function PopulateOption2(option1, option2)
{
var optionSelected = option1.val();
switch (optionSelected) {
case '---':
RePopulateOption2(option2, 0, 25, true, "---");
break;
case 'A':
RePopulateOption2(option2, 0, 25, false, 12);
break;
case 'B':
RePopulateOption2(option2, 20, 45, false, 22);
break;
}
}
function RePopulateOption2(option2, minVal, maxVal, showDash, defaultValue)
{
option2.empty();
var option2Items = '';
for (i=minVal; i<maxVal; i++) {
option2Items +='<option value="' + i + '">' + i + '</option>'
}
option2.html(option2Items);
if (showDash)
{
option2.children(":first").text("---");
}
option2.val(defaultValue);
}
</script>
<body>
<select id="option1List"></select>
<select id="option2List"></select>
<select id="option3List"></select>
<select id="option4List"></select>
</body>
</html>
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82:





by: dlcnetPosted on 2009-10-29 at 15:20:26ID: 25698833
forget about the first Question :) I found a solution myself. However I would like to make this as a function that I can send the parameters myself since there are 5 of this 2 drop down boxes on the page.
Any idea how I can do this?
Select allOpen in new window