- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-04-2021 06:08 AM
Hi, I need the selected dropdown value in the processing script, so that, based on the selected value, i need to redirect to some other page. Here is my HTML code:
<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
<g:ui_form>
<select id="sel" name="sel" onchange="show(this)" style="width:400px">
<option value="">-- Select --</option>
</select>
<g:ui_spacer />
<g:dialog_button_ok ok_id="ok_button" />
<input type="hidden" name="univValue" id="univValue" value="" />
</g:ui_form>
</j:jelly>
Client Script:
$j(function() {
var ga = new GlideAjax('FetchUniversities');
ga.addParam('sysparm_name', 'getUniversitiesList');
ga.getXML(callbackMethod);
});
function show(ele) {
alert(ele);
document.getElementById('univValue').value = ele.options[ele.selectedIndex].value;
}
function callbackMethod(response) {
var answer = response.responseXML.documentElement.getAttribute('answer');
answer = JSON.parse(answer);
try {
var ele = document.getElementById('sel');
var data1 = answer.data.identityProvider.providers;
for (var i = 0; i < data1.length; i++) {
ele.innerHTML = ele.innerHTML +
'<option value="' + data1[i]['idp'] + '">' + data1[i]['name'] + '</option>';
}
} catch (e) {
return;
}
}
Processing Script:
gs.info("checbox value is : " + univValue);
if (univValue != '') {
my_target = 'newpage.do';
} else {
my_target = 'navpage.do';
}
response.sendRedirect(my_target);
It looks like the "onchange" function is not firing, and in the console i'm getting "actionOK" is not defined error when i click on "OK" button.
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-05-2021 01:50 AM
Thanks for your reply. I've got it fixed by changing the onchange function name from "show" to "somethingelse".
Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-04-2021 09:48 PM
Hi,
any browser console error?
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
‎02-05-2021 01:50 AM
Thanks for your reply. I've got it fixed by changing the onchange function name from "show" to "somethingelse".
Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-05-2021 02:06 AM
Did you accidentally marked your own response as correct.
Would you mind marking my response as correct and helpful if I was able to help/guide you.
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader