- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-26-2016 08:15 AM
I have a UI Page that has a radio button with the following three options:
<input type="radio" name="status" id="single" style="text-align:left"> Single</input>
<input type="radio" name="status" id="married"> Married</input>
<input type="radio" name="status" id="married_but"> Married, but withhold at higher Single rate.</input>
I'm trying to pull the value of whatever the user chooses and insert it into a table where Single, Married, and Married but withhold at higher Single rate are all individual True/False fields. So ideally, if someone selects Single in the UI Page, the script would mark Single with an "x" indicating that it is true. I've tried the below code, which works great with text fields, but was wondering how to do it for radio buttons that map back to true/false fields.
function submitRequest()
{
var gr = new GlideRecord('u_table');
gr.initialize();
gr.variable_a= document.getElementById('A').value;
gr.variable_b= document.getElementById('B).value;
gr.variable_c= document.getElementById('C').value;
gr.insert();
}
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-26-2016 09:04 AM
Make the default value False for all the True/False field in the form, then try the below script.
function submitRequest()
{
var gr = new GlideRecord('u_table');
gr.initialize();
if (document.getElementById('single').checked) {
gr.variable_a = True;
}
if (document.getElementById('married').checked) {
gr.variable_a = True;
}
if (document.getElementById('married_but').checked) {
gr.variable_a = True;
}
gr.insert();
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-26-2016 09:04 AM
Make the default value False for all the True/False field in the form, then try the below script.
function submitRequest()
{
var gr = new GlideRecord('u_table');
gr.initialize();
if (document.getElementById('single').checked) {
gr.variable_a = True;
}
if (document.getElementById('married').checked) {
gr.variable_a = True;
}
if (document.getElementById('married_but').checked) {
gr.variable_a = True;
}
gr.insert();
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-26-2016 09:46 AM
Amazing, thanks Tanumoy! This code didn't work at first, but I simply deleted the quotes around "True" and it worked fantastically. Thanks again!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-26-2016 10:14 AM
Oops... that was a mistake. Thanks for correcting that... I have edited that... Thanks again.