Forum Moderators: open
$result = mssql_query("SELECT * FROM _store ORDER BY title", $link);
while ($row2 = mssql_fetch_row($result))
{
if ($row2[5]) $bcm_instore=$row2[5]; else $bcm_instore=$row2[6];
echo "
<tr>
<td bgcolor='#E6E8EC' align='left'><INPUT type='checkbox' NAME='bcm_cbox'</td>
<td bgcolor='#E6E8EC' align='left' width='100%' class='table'> $row2[1]</td>
<td bgcolor='#E6E8EC' align='left' width='100%' class='table'>
<INPUT class='menu' NAME='bod_price' type='text' SIZE='6' readonly='on' value='$row2[3] ð.'></td>
<td bgcolor='#E6E8EC' align='left' width='100%' class='table'>
<INPUT class='menu' NAME='bod_quantityinstore' type='text' SIZE='6' readonly='on' value='$bcm_instore'></td>
<td bgcolor='#E6E8EC' align='left' width='100%' class='table'>
<INPUT class='menu' NAME='bod_quantity' type='text' SIZE='6' value='0'></td>
<td bgcolor='#E6E8EC' align='left'><INPUT type='text' NAME='discount'SIZE='2'></td>
</tr>";
}
I have to do the following: when clicking checkbox the property "disable" of the "text"components of the same line changes to "true" and then back at the second click.
Thanks for the replies beforehand!
I have to edit only the last two fields in that line where checkbox is checked.
Could you give any examples, which will realize this.
Thanks for the replies beforehand!
P.S.: Why do you think that is not a good idea?
<input type="text" name="foo" value="hihi">
<input type="text" name="foo" value="hoho">
If a form with these fields (with identical names) is submitted to the server, only one of the fields will be sent. You probably want to send the other field as well.
The naming of the fields may also be important if you want to address the field with javascript. If the onclick event handler has to be generic, you'll need a logical naming system. An example:
<form>
<table>
<tr>
<td>bla <input type="checkbox" name="bcm_cbox_row1" onclick="dostuff('row1')"></td>
<td>bla <input type="text" name="bod_price_row1"></td>
<td>bla <input type="text" name="bod_quant_row1"></td>
</tr>
<tr>
<td>bla <input type="checkbox" name="bcm_cbox_row2" onclick="dostuff('row2')"></td>
<td>bla <input type="text" name="bod_price_row2"></td>
<td>bla <input type="text" name="bod_quant_row2"></td>
</tr>
</table>
<input type="submit">
</form>
These rows can easily be generated by a server-side script.
Now you could use just one javascript function to handle all the onclicks:
<script type="text/javascript">
function dostuff(row) {
var f = document.myform;
var clickstate = f["bcm_cbox_" + row].checked;
for (var i = 0; i < f.length; i++) {
if (f[i].type == 'text'
&& (f[i].name == "bod_price_" + row
¦¦ f[i].name == "bod_quant_" + row)) {
f[i].disabled = clickstate? true : false;
}
}
}
</script>
(the forum changes solid vertical pipes into ¦, so you'll need to change them back)