Razzy
07-09-2012, 07:35 PM
hey people,
i have four radio button options, with 4 textboxes linked to each of the radio button, the textboxes are disabled until a radio button is selected. when a particular radio button is selected, the textbox to which the selected radio button is linked is enabled, im trying have a default value setup for one of the textboxes, so if the radio button is selected, the textbox should show a a default value as soon as it is enabled
the coding so far is shown below:
<td>
• Lamb Ribs<input type="hidden" id="lamb7" value="4.99"/>
<br/>
Price: £4.99 per KG
</td>
<td bgcolor="green">
</td>
<td align="right" width="200px">
<input type="radio" name="lambR" onclick="lRibs(1)"/>in KG: <input type="text" name="lambRibs1" id="lambRibs1" size="2" value="" disabled="disabled"/>
<br/>
<br/>
<input type="radio" name="lambR" onclick="lRibs(2)"/>in lbs: <input type="text" name="lambRibs2" id="lambRibs2" size="2" value="" disabled="disabled"/>
<br/>
<br/>
<input type="radio" name="lambR" onclick="lRibs(3)"/>in money: £<input type="text" name="lambRibs3" id="lambRibs3" size="4" value="00.00" disabled="disabled"/>
<br/>
<br/>
<input type="radio" name="lambR" onclick="lRibs(4)"/>quantity: <input type="text" name="lambRibs4" id="lambRibs4" size="2" value="" disabled="disabled"/>
<script type = "text/javascript">
function lRibs (which) {
var len = document.forms[0].lambR.length; // how many radio buttons in group?
for (var i =1; i<=len; i++) { // for all the textboxes
document.forms[0]["lambRibs" + i].value = ""; // clear the field
document.forms[0]["lambRibs" + i].disabled = true; // disable the textbox
}
document.forms[0]["lambRibs" + which].disabled = false; // enable selected textbox
}
</script>
</td>
the radio button option that i am concerned with regarding the default value is:
<input type="radio" name="lambR" onclick="lRibs(3)"/>in money: £<input type="text" name="lambRibs3" id="lambRibs3" size="4" value="00.00" disabled="disabled"/>
i placed the value 00.00 on the textbox, however when i select the radio button, it is blank.
would reallly appreciate it if someone could help
thanks :)
i have four radio button options, with 4 textboxes linked to each of the radio button, the textboxes are disabled until a radio button is selected. when a particular radio button is selected, the textbox to which the selected radio button is linked is enabled, im trying have a default value setup for one of the textboxes, so if the radio button is selected, the textbox should show a a default value as soon as it is enabled
the coding so far is shown below:
<td>
• Lamb Ribs<input type="hidden" id="lamb7" value="4.99"/>
<br/>
Price: £4.99 per KG
</td>
<td bgcolor="green">
</td>
<td align="right" width="200px">
<input type="radio" name="lambR" onclick="lRibs(1)"/>in KG: <input type="text" name="lambRibs1" id="lambRibs1" size="2" value="" disabled="disabled"/>
<br/>
<br/>
<input type="radio" name="lambR" onclick="lRibs(2)"/>in lbs: <input type="text" name="lambRibs2" id="lambRibs2" size="2" value="" disabled="disabled"/>
<br/>
<br/>
<input type="radio" name="lambR" onclick="lRibs(3)"/>in money: £<input type="text" name="lambRibs3" id="lambRibs3" size="4" value="00.00" disabled="disabled"/>
<br/>
<br/>
<input type="radio" name="lambR" onclick="lRibs(4)"/>quantity: <input type="text" name="lambRibs4" id="lambRibs4" size="2" value="" disabled="disabled"/>
<script type = "text/javascript">
function lRibs (which) {
var len = document.forms[0].lambR.length; // how many radio buttons in group?
for (var i =1; i<=len; i++) { // for all the textboxes
document.forms[0]["lambRibs" + i].value = ""; // clear the field
document.forms[0]["lambRibs" + i].disabled = true; // disable the textbox
}
document.forms[0]["lambRibs" + which].disabled = false; // enable selected textbox
}
</script>
</td>
the radio button option that i am concerned with regarding the default value is:
<input type="radio" name="lambR" onclick="lRibs(3)"/>in money: £<input type="text" name="lambRibs3" id="lambRibs3" size="4" value="00.00" disabled="disabled"/>
i placed the value 00.00 on the textbox, however when i select the radio button, it is blank.
would reallly appreciate it if someone could help
thanks :)