Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - enabling and disabling a checkbox
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

enabling and disabling a checkbox

 Post Reply Post Reply
Author
simflex View Drop Down
Groupie
Groupie
Avatar

Joined: 10 November 2002
Location: United States
Status: Offline
Points: 63
Post Options Post Options   Thanks (0) Thanks(0)   Quote simflex Quote  Post ReplyReply Direct Link To This Post 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>
Back to Top
MorningZ View Drop Down
Senior Member
Senior Member
Avatar

Joined: 06 May 2002
Location: United States
Status: Offline
Points: 1793
Post Options Post Options   Thanks (0) Thanks(0)   Quote MorningZ Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
MorningZ View Drop Down
Senior Member
Senior Member
Avatar

Joined: 06 May 2002
Location: United States
Status: Offline
Points: 1793
Post Options Post Options   Thanks (0) Thanks(0)   Quote MorningZ Quote  Post ReplyReply Direct Link To This Post Posted: 27 February 2003 at 8:24am
btw, to save from copying, pasting, and saving, here's that above code running :)
Back to Top
simflex View Drop Down
Groupie
Groupie
Avatar

Joined: 10 November 2002
Location: United States
Status: Offline
Points: 63
Post Options Post Options   Thanks (0) Thanks(0)   Quote simflex Quote  Post ReplyReply Direct Link To This Post 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!

Back to Top
MorningZ View Drop Down
Senior Member
Senior Member
Avatar

Joined: 06 May 2002
Location: United States
Status: Offline
Points: 1793
Post Options Post Options   Thanks (0) Thanks(0)   Quote MorningZ Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
MorningZ View Drop Down
Senior Member
Senior Member
Avatar

Joined: 06 May 2002
Location: United States
Status: Offline
Points: 1793
Post Options Post Options   Thanks (0) Thanks(0)   Quote MorningZ Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
MorningZ View Drop Down
Senior Member
Senior Member
Avatar

Joined: 06 May 2002
Location: United States
Status: Offline
Points: 1793
Post Options Post Options   Thanks (0) Thanks(0)   Quote MorningZ Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
simflex View Drop Down
Groupie
Groupie
Avatar

Joined: 10 November 2002
Location: United States
Status: Offline
Points: 63
Post Options Post Options   Thanks (0) Thanks(0)   Quote simflex Quote  Post ReplyReply Direct Link To This Post 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!

Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.