- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-10-2015 09:11 AM
I have a UI Page with a group of Radio Buttons. I can't seem to make the array work because I have a ui_form instead of a form. I need to use the ui_form because I need to use the processing script area. Any help you can share will be greatly appreciated.
<g:ui_form id="ivr_survey">
<table id="survey" width="100%">
<TR>
<TD><SPAN class="normal"><B><h1>Agent Survey</h1></B></SPAN></TD></TR>
<TR>
<TD><SPAN class="normal"><B><h3>I had the tools and/or resources required to resolve the caller's issue to the caller's satisfaction</h3></B></SPAN></TD></TR>
<TR>
<TD><SPAN class="normal">
<input type="radio" id="score" name="score" value="1"> Strongly Disagree</input><BR></BR>
<input type="radio" id="score" name="score" value="2"> Disagree </input><BR></BR>
<input type="radio" id="score" name="score" value="3"> Netural</input><BR></BR>
<input type="radio" id="score" name="score" value="4"> Agree</input><BR></BR>
<input type="radio" id="score" name="score" value="5"> Strongly Agree</input>
</SPAN></TD>
</TR>
<td colspan="2" align="Left">
<button type="submit" id="submit" onclick="submitChanges();">Submit</button>
</td>
Client Script
function submitChanges(){
var tlscore;
var scores = document.ivr_survey.score;
// var radios = scores.elements.score;
for (var i = 0, len=scores.length; i< len; i++) {
if (scores[i].checked ) { // radio checked?
tlscore = scores[i].value; // if so, hold its value in tlscore
break; // and break out of for loop
}
}
Thanks
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-17-2015 02:27 PM
Here goes the latest. Compatible with IE
<?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 id="ivr_survey">
<table id="survey" width="100%">
<TR>
<TD><SPAN class="normal"><B><h1>Agent Survey</h1></B></SPAN></TD></TR>
<TR>
<TD><SPAN class="normal"><B><h3>I had the tools and/or resources required to resolve the caller's issue to the caller's satisfaction</h3></B></SPAN></TD></TR>
<TR>
<TD><SPAN class="normal">
<input type="radio" id="score1" name="score" value="1"> Strongly Disagree</input><BR></BR>
<input type="radio" id="score2" name="score" value="2"> Disagree </input><BR></BR>
<input type="radio" id="score3" name="score" value="3"> Netural</input><BR></BR>
<input type="radio" id="score4" name="score" value="4"> Agree</input><BR></BR>
<input type="radio" id="score5" name="score" value="5"> Strongly Agree</input>
</SPAN></TD>
</TR>
<td colspan="2" align="Left">
<button type="submit" id="submit" onclick="submitChanges();">Submit</button>
</td>
</table>
</g:ui_form>
</j:jelly>
function submitChanges(){
var scores = document.getElementsByName("score");
for (var i = 0, len=scores.length; i< len; i++) {
if (scores[i].checked ) { // radio checked?
tlscore = scores[i].value; // if so, hold its value in tlscore
alert('Selected option value: ' + tlscore);
break; // and break out of for loop
}
}
}
Thanks,
Berny
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-17-2015 09:23 AM
Sounds good! Please let me know if you have any questions.
Thanks,
Berny
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-14-2015 11:10 PM
I tried it on my personal instance and it works. Please give it a try.
Thanks,
Berny
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-15-2015 12:23 AM
Ohk. I didn't know that. Let me try this out on my instance. Is this documented somewhere @ w3schools?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-15-2015 08:59 PM
Hi Aswin, you can find a reference here:
http://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_radio_checked4
I hope this is helpful!
Thanks,
Berny
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-17-2015 09:28 AM
This didn't work for me the alert never shows. I tried something simuliar but it never works. The only way i have been successful is to just name each item differently for the Id and not use an array.
What version of Service Now are you working in. I am using Eureka