- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-23-2017 04:13 AM
I have an 'onLoad' script that will make the help text always visible. But instead, I need an onChange script that will display it conditionally. If 'designate_proxy' field = yes, the help text should expand:
How can I modify the script for this to work?:
var myVar = g_form.getControl('designate_proxy');
toggleHelp(myVar.id);
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-23-2017 06:04 AM
Hi Nicole,
Please try somthin like below:
function onChange(){
var val =g_form.getvalue('designate_proxy');
if(val == 'true'){
var elems = document.getElementsByClassName('sc-help-text annotation-wrapper');
for (var i=0;i<elems.length;i+=1){
if (elems[i].style.display === 'none') {
elems[i].style.display = 'block';
}
}
}
let me know if you not able to get becuase here sode i didn't tested but logic should be
first get the checkbox value and based on true false you have to display the helptext.
if its not works please let me know .
thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-23-2017 06:04 AM
Hi Nicole,
Please try somthin like below:
function onChange(){
var val =g_form.getvalue('designate_proxy');
if(val == 'true'){
var elems = document.getElementsByClassName('sc-help-text annotation-wrapper');
for (var i=0;i<elems.length;i+=1){
if (elems[i].style.display === 'none') {
elems[i].style.display = 'block';
}
}
}
let me know if you not able to get becuase here sode i didn't tested but logic should be
first get the checkbox value and based on true false you have to display the helptext.
if its not works please let me know .
thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-23-2017 06:16 AM
This did not work. I tried:
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
//Type appropriate comment here, and begin script below
var val =g_form.getvalue('designate_proxy');
if(val == 'Yes'){
var elems = document.getElementsByClassName('sc-help-text annotation-wrapper');
for (var i=0;i<elems.length;i+=1){
if (elems[i].style.display === 'none') {
elems[i].style.display = 'block';
}
}
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-23-2017 06:22 AM
Hi Nicole,
Did you give a try for the script provided by me in earlier comment?
Please let me know if any concerns.
you will find it easy to hide/show if you use jquery.
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-23-2017 06:39 AM
Hi
designate_proxy is check box right. so you should try 'true' instead of 'yes' and
and in getvalue..v should be capital.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-23-2017 06:44 AM
The field is a 'yes/no' field. Once I capitalized the 'v', it worked! Thank you.