Capture Checkbox in UI Page

Elias11
Giga Expert

Hi Experts

 

I want to create a checkbox in ui page

I have added this checkbox code in the HTML Tag

<g:ui_checkbox name="changeBox" value="${false}"/>  

<label>Check Box</label>

 

 

now I want to capture this value in the client script of the UI Page.

 

if check box is true then do that if false then this.

 

how can I do that?

 

Thanks

Elias

1 ACCEPTED SOLUTION

Mahira
Tera Guru

Hi Elias,



You can check out some of the out of the box UI Pages which uses checkbox.


I just checked this ui page named "activate_plugin_confirm".



In this servicenow has given a unique id to the checkbox field. This id can then be used in the processing script directly.



To know more you can open the code for this ui page.




Or you can use something like


<input type="checkbox" name="somename" id="someid" title="sometitle" value="somevalue" onclick="openClicked(this);" />



Then define a function in your UI Page client script section like this



function openClicked(cb)


{


alert(cb.checked);//this will show a popup if the checkbox is checked or not.


}



Hope this helps


View solution in original post

4 REPLIES 4

Mahira
Tera Guru

Hi Elias,



You can check out some of the out of the box UI Pages which uses checkbox.


I just checked this ui page named "activate_plugin_confirm".



In this servicenow has given a unique id to the checkbox field. This id can then be used in the processing script directly.



To know more you can open the code for this ui page.




Or you can use something like


<input type="checkbox" name="somename" id="someid" title="sometitle" value="somevalue" onclick="openClicked(this);" />



Then define a function in your UI Page client script section like this



function openClicked(cb)


{


alert(cb.checked);//this will show a popup if the checkbox is checked or not.


}



Hope this helps


Hi Mahira



this is exaclty what I was searching for..



Many thanks


Elias


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

M_48
Tera Contributor

Did you find a solution to your problem?