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

Fix for issue where cannot uncheck (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

Dig deeper on Domino Resources - Part 6

0 comments

Oldest 

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:

SearchWinIT

Search400

  • iSeries tutorials

    Search400.com's tutorials provide in-depth information on the iSeries. Our iSeries tutorials address areas you need to know about...

  • V6R1 upgrade planning checklist

    When upgrading to V6R1, make sure your software will be supported, your programs will function and the correct PTFs have been ...

  • Connecting multiple iSeries systems through DDM

    Working with databases over multiple iSeries systems can be simple when remotely connecting logical partitions with distributed ...

SearchEnterpriseLinux

SearchVirtualDataCentre.co.uk

Close