Hi guys,
Im trying to have a drop down with values 1-5 and when a user clicks 2 for example it then automatically puts in 2 input fields and if 3 then three input fields etc.. here is my code but its not working correctly can anyone see why?
<html>
<head>
<script language="JavaScript" type="text/javascript">
function showdivs() {
totaldivs = document.forms.consult.sales.value;
totaldivs++;
for (j=1; j<6; j++) { document.getElementById("sales" + j).style.display = 'none'; }
for (i=1; i<totaldivs; i++) { document.getElementById("sales" + i).style.display = 'block'; }
}
</script>
</head>
<body>
<form name="consult" id="consult" >
<table>
<tr>
<td ><select name="sales" id="sales" onChange="showdivs();">
<option value="0">Sales</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
</select></td>
<div name="sales" id="sales" style="display: none;">
</tr>
<td><input name="sales_names" /></td>
</tr>
</div>



Reply With Quote


Bookmarks