Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Check Box and blanking out

Status
Not open for further replies.

Tarbuza

Technical User
Dec 13, 2000
56
US
I have the following display on the screen:

checkbox Item Name Condition Qty
Computer Usable 5
Monitor Unusable 3
Hard Drive Usable 6

Item Names and check boxes are displayed. User selects condtion from the drop down list which can be either Usable or Unusable. User types in Qty.

My question is if user selects computer and hard drive, if by mistake a user has selected condition for Monitor or typed qty for Monitor - it should blank out at the time of submission. Remember Condition and Qty are two separate fields. Item and Check box is one field. How can I associate Item name to condition and qty? How can I blank out the value for condition or qty for those items which are not selected?

Any helps would be greatly appreciated. Thanks in advance.
 
here's one way:
[tt]
<html>
<head>
<title></title>

<script language=&quot;javascript&quot;>
// global element arrays
var arCB = [], arSel = [], arTF = [];

function initForm() {
e = document.forms[0].elements;
// set up arrays of element types
for (x = 0; x < e.length; x++) {
switch(e[x].type) {
case &quot;checkbox&quot;:
arCB[arCB.length] = e[x];
e[x].index = arCB.length - 1;
break;
case &quot;select-one&quot;:
arSel[arSel.length] = e[x];
break;
case &quot;text&quot;:
arTF[arTF.length] = e[x];
break;
}
}

// attach function to checkboxes onclick
for (x = 0; x < arCB.length; x++) {
arCB[x].onclick = checkRow;
}
}

function checkRow() {
arSel[this.index].selectedIndex = 0;
arSel[this.index].disabled = !this.checked;
arTF[this.index].value = &quot;&quot;;
arTF[this.index].disabled = !this.checked;
}
</script>

<style type=&quot;text/css&quot;>
</style>
</head>

<body onLoad=&quot;initForm();&quot;>
<form>
<table align=&quot;center&quot; border=&quot;1&quot;>
<tr>
<th> </th>
<th>Item Name</th>
<th>Condition</th>
<th>Qty</th>
</tr>
<tr>
<td><input type=&quot;checkbox&quot; name=&quot;cb&quot; value=&quot;&quot; /></td>
<td>Computer</td>
<td>
<select name=&quot;condition&quot; disabled=&quot;true&quot;>
<option>Choose:</option>
<option>Usable</option>
<option>Unusable</option>
</select>
</td>
<td><input type=&quot;text&quot; name=&quot;qty&quot; size=&quot;3&quot; disabled=&quot;true&quot; /></td>
</tr>
<tr>
<td><input type=&quot;checkbox&quot; name=&quot;cb&quot; value=&quot;&quot; /></td>
<td>Monitor</td>
<td>
<select name=&quot;condition&quot; disabled=&quot;true&quot;>
<option>Choose:</option>
<option>Usable</option>
<option>Unusable</option>
</select>
</td>
<td><input type=&quot;text&quot; name=&quot;qty&quot; size=&quot;3&quot; disabled=&quot;true&quot; /></td>
</tr>
<tr>
<td><input type=&quot;checkbox&quot; name=&quot;cb&quot; value=&quot;&quot; /></td>
<td>Hard Drive</td>
<td>
<select name=&quot;condition&quot; disabled=&quot;true&quot;>
<option>Choose:</option>
<option>Usable</option>
<option>Unusable</option>
</select>
</td>
<td><input type=&quot;text&quot; name=&quot;qty&quot; size=&quot;3&quot; disabled=&quot;true&quot; /></td>
</tr>
</table>
</form>
</body>
</html>

[/tt]
=========================================================
if (!succeed) try();
-jeff
 
Thanks a million for solution. I will implement tomorrow. If I have any further questions, I will need further help. Thanks again.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top