This forum is closed to new posts and responses. Individual names altered for privacy purposes. The information contained in this website is provided for informational purposes only and should not be construed as a forum for customer support requests. Any customer support requests should be directed to the official HCL customer support channels below:

HCL Software Customer Support Portal for U.S. Federal Government clients
HCL Software Customer Support Portal



Nov 5, 2013, 5:58 AM
3 Posts

Xpages Checkbox issue

  • Category: Debugging
  • Platform: Windows
  • Release: 8.5.3
  • Role: Developer
  • Tags: Xpages Checkbox issue
  • Replies: 2

Xpages Checkbox issue

All checkboxes belong to a checkbox group.

requirement:    1.When None is checked , other checkboxes should be unchecked

                            2.When any other checkbox is checked, None should be unchecked

To achieve this I have used following Client Side Java Script code in onclick event of the checkbox group.

The 1st requirement is achieved ,but to achieve 2nd I need some condition to use if-else statement.

and put 1st block under if statement and 2nd block under else.

Is there any way to achieve this?

----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

var elements = document.getElementsByName("#{id:chkBoxGrpAudit}");

1st block

---------------------------------------------------------------------------------------------------------------------
//If none is checked, uncheck other check boxes
if (elements[0].checked == true) {
    for (var i = 1; i < elements.length; i++) {
        elements[i].checked = false;   
    }  
}
------------------------------------------------------------------------------------------------------------------------

2nd block

------------------------------------------------------------------------------------------------------------------------
//If any other checkbox is checked, uncheck none
for (var i = 1; i < elements.length; i++) {

    if (elements[i].checked == true) {
        elements[0].checked = false;
    }
}

-----------------------------------------------------------------------------------------------------------------------------

Nov 7, 2013, 2:15 AM
8 Posts
uncheck/check based on value

your code i think is the right code there

 

var elements = document.getElementsByName("#{id:chkBoxGrpAudit}");

  if (elements[0].checked == true) {

    for (var i = 1; i < elements.length; i++) {
        elements[i].checked = false;   
    }     

  } else {

    for (var i = 1; i < elements.length; i++) {

     if (elements[i].checked == true) {
        elements[0].checked = false;
     }
   }

  }

 

Nov 7, 2013, 12:46 PM
3 Posts
Regarding solution

Thank u Glenn for your response.

But if I check none and save the doc, Then open the doc and try to select any other check box, that will not get checked , because control will go to if block since none is checked.

So the condition should be if none is checked and any other checkbox is clicked , the checkbox should get checked and  none should get unchecked

 


This forum is closed to new posts and responses. Individual names altered for privacy purposes. The information contained in this website is provided for informational purposes only and should not be construed as a forum for customer support requests. Any customer support requests should be directed to the official HCL customer support channels below:

HCL Software Customer Support Portal for U.S. Federal Government clients
HCL Software Customer Support Portal