- 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:47 AM
Please mark as correct.. thanks
Regards,
Prakash Ranjan
On 23 Jun 2017 19:15, "nicolemccray" <community-no-reply@servicenow.com>
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-23-2017 07:05 AM
If I change field value to 'No', the help text does not clear, it still displays.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-23-2017 07:07 AM
Hi Nicole,
I tried the option Prakash mentioned in my demo instance and it was not working for the other condition.
Can you try script shared by me in earlier comment.
Any concerns let me know.
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 07:32 AM
Hi Nicole,
write one more condition if value is no the set below line.
ele[i].style.display = 'none';
Thanks
Please let me know if still you are facing the issue.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-23-2017 07:39 AM
example code:
function onChange(){
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';
}
}
}
if(val == 'no'){
var elem = document.getElementsByClassName('sc-help-text annotation-wrapper');
for (var i=0;i<elem .length;i+=1){
if (elem [i].style.display === 'none') {
elem[i].style.display = 'none';
}
}
//NB: I did't try this code but its should work..let me know if still u facing issue then i will test the code and update you thanks