Forum Moderators: open
[edited by: tedster at 3:54 pm (utc) on Feb 8, 2010]
[edit reason] switch addresses to example.com [/edit]
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01
Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!-- doctype on one line -->
<html lang="en">
<head>
<title>Test</title>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<script type="text/javascript">
window.onload=function() { attachBehaviors(); };
function attachBehaviors() {
if (document.getElementById('productpr1')) {
document.getElementById('productpr1').onchange=function() {
Display(this,this.selectedIndex);
};
}
}
function Display(obj,selind) {
if (! document.getElementById(obj.id)) {
alert('Oops! Something is not id\'ed correctly ' + obj.id);
return;
}
var divs = Array('p1-div','p2-div');
var opts = obj.options[selind].value.split(':');
var div = opts[opts.length-1]; // takes last item, arrays are zero based.
for (j=0;j<divs.length;j++) {
if (document.getElementById(divs[j])) {
document.getElementById(divs[j]).style.display=
(divs[j]==div)?'block':'none';
}
}
}
</script>
</head>
<body>
<form action="http://ww7.example.com/cf/addmulti.cfm" method="post" name="form1">
<input type="hidden" name="userid" value="9437628">
<input type="hidden" name="return" value="example.net/scripts/cart.php">
<p style="text-align:center;">Option :
<input type="hidden" value="1" name="qty1">
<select name="productpr1" id="productpr1">
<option selected value="">please select</option>
<option value="Platinum 2 seater fabric sofabed:539:p1-div">2 seater fabric sofabed</option>
<option value="Platinum 2 seater fabric fixed sofa:499:p2-div">2 seater fabric fixed sofa</option>
</select>
</p>
<p id="p1-div" style="display:none;text-align:center;">
<select name="product1[]" id="product1-select">
<option selected value="">please select</option>
<option value=", anthracite fabric">fabric : anthracite</option>
<option value=", beige fabric">fabric : beige</option>
</select>
</p>
<p id="p2-div" style="display:none;text-align:center;">
<select name="product1[]" id="product2-select">
<option selected value="">please select</option>
<option value=", bitter leather">leather : bitter</option>
<option value=", chestnut leather">leather : chestnut</option>
</select>
</p>
</form>
</body>
</html>