I need help please. I’m trying to validate when a user selects an item from the equipment select list they must select a reason code as to why they are ordering the item. This must work across all rows. Also the field to the left of the equipment select list should allow the user to key in the item # of the part and the select list automatically gets selected with the part. How the heck do I do this. I tried the functions I have included but they suck! Please help me Tracy
[CODE]<script>
function validateReason(){
var tr, i=1;
while(tr=document.getElementById(‘Child’+(i++))){
var txtV=tr.getElementsByTagName(‘input’)[0].value
var selS=tr.getElementsByTagName(‘select’)[0].selectedIndex;
if(txtV.length>0&&selS==0){alert(‘If you enter a quantity you must select a reason!’);return false}
}
}
function change_uids(uid){
var uids = document.getElementById(“uids”);
for (var i=0; i<uids.options.length; i++){
if (uids.options[i].value == uid.value){
uids.options[i].selected = true;
break;
}
}
}
</script>
<form method=”POST” onsubmit=”return validateReason(this) ;” action=”” name=”theForm” >
<table>
<tr id=’Child1′>
<td><input type = ‘text’ MAXLENGTH=’3′
style = ‘width:40px’; class=’textfield’ name=’quantity[]’ ></td>
<td><input type = ‘text’ MAXLENGTH=’6′
style = ‘width:60px’; class=’textfield’ onkeyup=’change_uids(this)’ id=’uid’ name=’wic[]’ ></td>
<td>
<select size=’1′ STYLE=’width: 270px’ class=’smallDrop’ id=’uids’ name=’itemid[]’>
<option value=” > – Choose Equipment – </option>
<option value=’112233′ > ZENTIH – </option>
<option value=’332244′ > EMERSON – </option>
<option value=’0949′ >LG</option>
<option value=’99623′ >SONY</option>
</select>
</td> <td>
<select size=’1′ STYLE=’width: 130px’ class=’smallDrop’ name=’reason_codes[]’>
<option value=” > – SET REASON – </option>
<option value=’BROKEN’ >BROKEN</option>
<option value=’ENTERED’ >ENTERED</option>
<option value=’SHORT’ >SHORT</option>
</select>
</td></tr>
<tr id=’Child2′>
<td><input type = ‘text’ MAXLENGTH=’3′
style = ‘width:40px’; class=’textfield’ name=’quantity[]’ ></td>
<td><input type = ‘text’ MAXLENGTH=’6′
style = ‘width:60px’; class=’textfield’ onkeyup=’change_uids(this)’ id=’uid’ name=’num[]’ ></td>
<td>
<select size=’1′ STYLE=’width: 270px’ class=’smallDrop’ id=’uids’ name=’itemid[]’>
<option value=” > – Choose Equipment – </option>
<option value=’112233′ > ZENTIH – </option>
<option value=’332244′ > EMERSON – </option>
<option value=’0949′ >LG</option>
<option value=’99623′ >SONY</option>
</select>
</td> <td>
<select size=’1′ STYLE=’width: 130px’ class=’smallDrop’ name=’reason_codes[]’>
<option value=” > – SET REASON – </option>
<option value=’BROKEN’ >BROKEN</option>
<option value=’ENTERED’ >ENTERED</option>
<option value=’SHORT’ >SHORT</option>
</select>
</td></tr>
<tr id=’Child3′>
<td><input type = ‘text’ MAXLENGTH=’3′
style = ‘width:40px’; class=’textfield’ name=’quantity[]’ ></td>
<td><input type = ‘text’ MAXLENGTH=’6′
style = ‘width:60px’; class=’textfield’ onkeyup=’change_uids(this)’ id=’uid’ name=’part[]’ ></td>
<td>
<select size=’1′ STYLE=’width: 270px’ class=’smallDrop’ id=’uids’ name=’itemid[]’>
<option value=” > – Choose Equipment – </option>
<option value=’112233′ > ZENTIH – </option>
<option value=’332244′ > EMERSON – </option>
<option value=’0949′ >LG</option>
<option value=’99623′ >SONY</option>
</select>
</td>
<td>
<select size=’1′ STYLE=’width: 130px’ class=’smallDrop’ name=’reason_codes[]’>
<option value=” > – SET REASON – </option>
<option value=’BROKEN’ >BROKEN</option>
<option value=’ENTERED’ >ENTERED</option>
<option value=’SHORT’ >SHORT</option>
</select>
</td></tr>
</table>
<input type=”submit” value=”SUBMIT” name=”submit”>
</form>