How to select/deselect checkbox from client script of UI Page

dfesenbek
Giga Contributor

I have a UI Page that prompts a window with a few fields to a user, and when they enter a specific field I want to select or deselect a checkbox on the prompt from the Client Script. I've attempt different code to accomplish this but haven't succeeded so far.  Below is the HTML code for the checkbox:

    <tr id="standardrow">
        <td><label for="standard">Standard?</label></td>
        <td><g2:ui_checkbox id="standard" name="standard" value="false" /></td>
    </tr>

Here is the Client Script code to set the "Standard" checkbox on:

gel('standard').checked = true;    //doesn't check prompt checkbox

I have a quantity field on the prompt and code gel('myquantity').value = '9'; does set the filed to "9". What is my code missing to set the checkbox?

1 ACCEPTED SOLUTION

Cuong Phan
Kilo Sage

Hi dfe,

 

Please use this:

gel("ni.standard").checked = true;

 

Mark Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.

 

Cuong Phan

DXC Consultant.

Regards,
Cuong Phan
ServiceNow Technical Lead

View solution in original post

2 REPLIES 2

Cuong Phan
Kilo Sage

Hi dfe,

 

Please use this:

gel("ni.standard").checked = true;

 

Mark Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.

 

Cuong Phan

DXC Consultant.

Regards,
Cuong Phan
ServiceNow Technical Lead

Erica2
Tera Contributor

Hello,

Can someone please help?  I have been searching on the web for many days, but I have no luck of finding an example of the below request. 

I need a button on the incident form. When a user click on the button, a popup window with 4 checkboxes and a OK and Cancel buttons. If a user select one or all checkboxes, then click on the OK button.  The select checkboxes information will populated in either the comment or work notes field on an incident form. If a user click on a cancel button, then it will close the popup window.

Thank you in advance