Tip

When you can't deselect a checkbox item on the Web...

Issue:

You cannot uncheck (deselect) a checked item in a Checkbox field when updating a Notes document via a Web browser. The checkbox item will remain checked the next time you open the document.

The core problem is the way HTML form data is returned to the Domino server upon a submit. When you submit an HTML form, the name-value pairs of all the fields are assembled and sent to the Domino server. For Checkbox fields, the Web browser will only send the "checked" values. So if an item is not checked for a Checkbox field, no information for that checkbox item is sent to the Domino server. Therefore, Domino does not know to remove that item from the Notes field when the document is saved.

Solution:

Force the unchecked items in the Checkbox field to be sent to the server by setting the items as checked and the value to null at the time the document is submitted to the Domino server.

Code Sample:

Following is a sample of the code we use to force unchecked checkbox items to be passed to the Domino server when a document is submitted via a Web browser. This solution works for both single item and multiple item Checkbox fields. The only issue I can see is that, for a multiple item Checkbox field, a "Text List" type of field is always generated for the Notes field, with a null value for each unchecked item in the selection list. This is contrary to the Notes interface which generates a plain "Text" field with a null value if no items are checked for a multiple item Checkbox field or a "Text List" type of field with only the checked values listed.


1. A "Save & Close" action is used on the form for the user to submit a new or updated document via a Web browser; we do not use the "onSubmit" form event. The "Save & Close" action has the following JavaScript code:

if (validateFormFields()) 
  { 
  window.document.forms[0].submit(); 
  } 

2. The following code is in the "JS Header" event for the form:

var thisform = window.document.forms[0];
// Function to validate the fields on this form 
function validateFormFields() 
   { 
   if (validateFieldRqrd(thisform.Subject, "text", "Action Item Title")); else return false; 
   if (validateFieldRqrd(thisform.Status, "select", "Action Item Status")); else return false; 
   ... 
   .... all other field validations go here ... 
   ...
   // Force null values to be returned back the Domino server (from the Web) 
   // for any unchecked items in the Checkbox fields 
   forceUncheckedItems(thisform.CheckBoxFieldA); 
   forceUncheckedItems(thisform.CheckBoxFieldB); 
   forceUncheckedItems(thisform.CheckBoxFieldC);
    return true; 
   } 
   // End of Function: validateFormFields function 

forceUncheckedItems(objField) 
   { 
   // This function forces a null value back to the Domino server 
   // for each unchecked selection item in a Checkbox field. 
   // Notes: 
   // -- This function can only be called at the point where the  
   //     document will be submitted to the server; that is that all 
   //     validations have passed and the last action is to submit it. 
   //     It may cause data entry problems if the user is returned back 
   //     to the form after this function has been run. 
   // 
   // -- This function must only be used when submitting  
   //     documents from the Web.    

var index;

    // Test for a multiple item selection list 
   if (objField[0]) 
      { 
      // Loop through multiple item selection list 
      for (index = 0; index < objField.length; ++index) 
         { 
         if (objField[index].checked == false) 
            { 
            objField[index].checked = true; 
            objField[index].value = ""; 
            } 
         } 
      } 
   else 
      { 
      // Single item selection list 
      if (objField.checked == false) 
         { 
         objField.checked = true; 
         objField.value = ""; 
         } 
      } 
   } 
   // End of Function: forceUncheckedItem

This was first published in November 2001

There are Comments. Add yours.

 
TIP: Want to include a code block in your comment? Use <pre> or <code> tags around the desired text. Ex: <code>insert code</code>

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
Sort by: OldestNewest

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

Disclaimer: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.