KyleVA
05-28-2009, 12:59 AM
I'm trying to make this dynamic because the option values are going to change on the fly.
Using the example provided via the code.. If you choose 'Selection 1' in the first drop down menu - the second drop down will only display options that have an "A" contained within the value. If you choose 'Selection 2' in the first drop down - the second drop down will only display options that have a "B" contained within the value.
I'm new to Javascript programming and I'm just having trouble figuring out a way to perform an operation to check each of the values within the second drop-down's options.
I'm sure it's very simple - but I'm new to this so I appreciate any help at all.
<html>
<head>
<script type="text/javascript">
function assignSelection() {
elem = document.getElementById("selection");
elem.disabled = false;
}
function loadPage()
{
//var string = "0005B"
//if (string.indexOf("B")!=-1) {}
}
function onSelect() {
}
</script>
</head>
<body onLoad="loadPage()">
<form name="oForm">
<p>
<select name="main" onchange="assignSelection()">
<option value="Select"> SELECT ONE </option>
<option value="SelectA"> Selection 1 </option>
<option value="SelectB"> Selection 2 </option>
</select>
</p>
<p>
<select name="products" id="selection" onChange="onSelect()" disabled>
<option value="Select"> Select One </option>
<option value="1000A" name="attr"> Selection 1 - 1000 </option>
<option value="1001A" name="attr"> Selection 1 - 1001 </option>
<option value="1002A" name="attr"> Selection 1 - 1002 </option>
<option value="1000B" name="attr"> Selection 2 - 1000 </option>
<option value="1001B" name="attr"> Selection 2 - 1001 </option>
<option value="1002B"> Selection 2 - 1002 </option>
</select>
</p>
</form>
</body>
</html>
Edit: Ugh, still not much luck figuring it out. Damn.
Using the example provided via the code.. If you choose 'Selection 1' in the first drop down menu - the second drop down will only display options that have an "A" contained within the value. If you choose 'Selection 2' in the first drop down - the second drop down will only display options that have a "B" contained within the value.
I'm new to Javascript programming and I'm just having trouble figuring out a way to perform an operation to check each of the values within the second drop-down's options.
I'm sure it's very simple - but I'm new to this so I appreciate any help at all.
<html>
<head>
<script type="text/javascript">
function assignSelection() {
elem = document.getElementById("selection");
elem.disabled = false;
}
function loadPage()
{
//var string = "0005B"
//if (string.indexOf("B")!=-1) {}
}
function onSelect() {
}
</script>
</head>
<body onLoad="loadPage()">
<form name="oForm">
<p>
<select name="main" onchange="assignSelection()">
<option value="Select"> SELECT ONE </option>
<option value="SelectA"> Selection 1 </option>
<option value="SelectB"> Selection 2 </option>
</select>
</p>
<p>
<select name="products" id="selection" onChange="onSelect()" disabled>
<option value="Select"> Select One </option>
<option value="1000A" name="attr"> Selection 1 - 1000 </option>
<option value="1001A" name="attr"> Selection 1 - 1001 </option>
<option value="1002A" name="attr"> Selection 1 - 1002 </option>
<option value="1000B" name="attr"> Selection 2 - 1000 </option>
<option value="1001B" name="attr"> Selection 2 - 1001 </option>
<option value="1002B"> Selection 2 - 1002 </option>
</select>
</p>
</form>
</body>
</html>
Edit: Ugh, still not much luck figuring it out. Damn.