Print Page | Close Window

persisting a checkmark

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Classic ASP Discussion
Forum Description: Discussion on Active Server Pages (Classic ASP).
URL: https://forums.webwiz.net/forum_posts.asp?TID=807
Printed Date: 29 March 2026 at 2:55am
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: persisting a checkmark
Posted By: simflex
Subject: persisting a checkmark
Date Posted: 07 March 2003 at 12:29pm

Before I added the updateCookie function to this html, this code works fine like it is intended to do.
It enables a checkbox while disabling the subsequent ones.
But the problem that I am having now is when a check is placed on a checkbox and you click the save button to save that record, the checkbox becomes unchecked.
I am trying to ensure that once a check is placed on a checkbox, that that checkbox remains checked even after you close and reopne the page.
I am having problem doing this with a cookie.
Can I get your help, please?

<HTML>
<HEAD>
<TITLE>enable</TITLE>
<script language="javascript">
<!--
var numOfBoxes = 8;
function enable(inBox) {
 if (!document.forms['myForm']['cb' + inBox].checked) {
  // If the user unchecked a box, then disable all after it
  for (var i = inBox + 1; i <= numOfBoxes; i ++) {
   document.forms['myForm']['cb' + i].checked = false;
   document.forms['myForm']['cb' + i].disabled = true;
  }
 }
 else {
  // User checked a box, so enable the next
  document.forms['myForm']['cb' + (inBox+1)].disabled = false;
 }
}
//-->
</script>

<script language="javascript">
<!--
function updateCookie()
{
  document.cookie=document.myForm.cookie.value
  location.reload(true)
}
//-->
</script>

</HEAD>
<BODY>
<form name="myForm">
<table>
<tr>
    <td>Identify Objectives
  <input type="checkbox" name="cb1" id="cb1" onClick="enable(1),updateCookie()" >

  Evaluate Requirements
  <input type="checkbox" name="cb2" id="cb2" onClick="enable(2),updateCookie()" DISABLED>

  Design
       <input type="checkbox" name="cb3" id="cb3" onClick="enable(3);updateCookie()" DISABLED>


        Initial Draft
  <input type="checkbox" name="cb4" id="cb4" onClick="enable(4),updateCookie()" DISABLED>

  Review
  <input type="checkbox" name="cb5" id="cb5" onClick="enable(5),updateCookie()" DISABLED>

  Revision
       <input type="checkbox" name="cb6" id="cb6" onClick="enable(6),updateCookie()" DISABLED>

        Final Production
  <input type="checkbox" name="cb7" id="cb7" onClick="enable(7),updateCookie()" DISABLED>

  Documentation
  <input type="checkbox" name="cb8" id="cb8" DISABLED>
 </td>

</tr>
</table>
</form>
</BODY>
</HTML>




Replies:
Posted By: MorningZ
Date Posted: 07 March 2003 at 3:46pm
well, you have this line

document.cookie=document.myForm.cookie.value

but no where do you have a form field called "cookie"

i'm not even sure why you take this multiple checkbox route, it'd be so much easier to force them to go in steads with just flat out code, this code is too "cute", especially now that its 8 steps

-------------
Contribute to the working anarchy we fondly call the Internet



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net