| Author |
Topic Search Topic Options
|
simflex
Groupie
Joined: 10 November 2002
Location: United States
Status: Offline
Points: 63
|
Post Options
Thanks(0)
Quote Reply
Topic: enabling and disabling a checkbox Posted: 27 February 2003 at 7:41am |
|
Can someone please help me with this. I have already come up with the code but it is not working. What I really need out of this code is to disable all checkboxes except the first one so that processing can be done with that first one. Once processing is complete with the first one, a checkmark is placed on the checkbox disabling and the next checkbox is enabled for processing. Once that next one is processed, a checkmark is placed on the checkbox beside it disabling it while enabling the next checkbox for processing until all are processed. So far, once a checkmark is placed on the first one, everything is disabled. here is the code i have so far:
<HTML> <HEAD> <TITLE>enable</TITLE> <script language="javascript"> function enable(inBox){ //check to make sure that the last box hasn't been reached. lastBox = 3; //disable current box eval("document.myForm.cb" + inBox + ".disabled = true"); //enable next box (if not finished) if (inBox < lastBox){ inBox = inBox + 1; eval("document.myForm." + inBox + ".disabled = false"); } } </script>
</HEAD> <BODY> <form name="myForm"> <table> <tr> <td>First Order <input type=checkbox name=cb1 onClick="enable(1)"> <td>Second Order <input type=checkbox name=cb2 onClick="enable(2)" DISABLED> <td>Third Order <input type=checkbox name=cb3 onClick="enable(3)" DISABLED> </td> </tr> </table> </form> </BODY> </HTML>
|
 |
MorningZ
Senior Member
Joined: 06 May 2002
Location: United States
Status: Offline
Points: 1793
|
Post Options
Thanks(0)
Quote Reply
Posted: 27 February 2003 at 8:21am |
|
"I have already come up with the code but it is not working"
then you haven't come up witht he code yet, lol
here's some that does what i think you are trying to accomplish
<%@ Language=VBScript %>
<HTML>
<HEAD>
<TITLE>enable</TITLE>
<script language="javascript">
<!--
var numOfBoxes = 3;
function enable(inBox) {
for (var i = inBox + 1; i <= numOfBoxes; i ++) {
document.forms['myForm']['cb' + i].disabled = false;
}
}
//-->
</script>
</HEAD>
<BODY>
<form name="myForm">
<table>
<tr>
<td>First Order
<input type="checkbox" name="cb1" id="cb1" onClick="enable(1)">
</td>
<td>
Second Order
<input type="checkbox" name="cb2" id="cb2" onClick="enable(2)" DISABLED>
</td>
<td>
Third Order
<input type="checkbox" name="cb3" id="cb3" onClick="enable(3)" DISABLED>
</td>
</tr>
</table>
</form>
</BODY>
</HTML>
|
|
Contribute to the working anarchy we fondly call the Internet
|
 |
MorningZ
Senior Member
Joined: 06 May 2002
Location: United States
Status: Offline
Points: 1793
|
Post Options
Thanks(0)
Quote Reply
Posted: 27 February 2003 at 8:24am |
btw, to save from copying, pasting, and saving, here's that above code running :)
|
 |
simflex
Groupie
Joined: 10 November 2002
Location: United States
Status: Offline
Points: 63
|
Post Options
Thanks(0)
Quote Reply
Posted: 27 February 2003 at 8:51am |
MorningZ, thanks a bunch but it is still not working correctly.
The only time the next checkbox is actived should be after the current checkbox is checked.
For instance, if the first checkbox for first order has not been checked, the rest should be disabled making it impossible for anyone to check them until the first one is checked off as being completed.
again, thanks for the help!
|
 |
MorningZ
Senior Member
Joined: 06 May 2002
Location: United States
Status: Offline
Points: 1793
|
Post Options
Thanks(0)
Quote Reply
Posted: 27 February 2003 at 8:56am |
|
so are you saying/asking that the code needs to also deactivate a later checkbox if a user unchecks a box?
ya know, i'd really try to help, but you need to explain better
|
|
Contribute to the working anarchy we fondly call the Internet
|
 |
MorningZ
Senior Member
Joined: 06 May 2002
Location: United States
Status: Offline
Points: 1793
|
Post Options
Thanks(0)
Quote Reply
Posted: 27 February 2003 at 9:04am |
wait i get it now... 5 mins i'll have diff code up
|
|
Contribute to the working anarchy we fondly call the Internet
|
 |
MorningZ
Senior Member
Joined: 06 May 2002
Location: United States
Status: Offline
Points: 1793
|
Post Options
Thanks(0)
Quote Reply
Posted: 27 February 2003 at 9:09am |
what about this?
just "View Source" to see the javascript
|
|
Contribute to the working anarchy we fondly call the Internet
|
 |
simflex
Groupie
Joined: 10 November 2002
Location: United States
Status: Offline
Points: 63
|
Post Options
Thanks(0)
Quote Reply
Posted: 27 February 2003 at 10:38am |
Perfect MorningZ!
This is exactly what I need.
You are great and I thank you!
I hope to get to your level one day!
|
 |