- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-25-2017 02:08 AM
i have created a ui page which does a glide record query and returns value. i need to set these values in a text field. i am doing a glide ajax query to return value in client script.
this is the html part
<td><input id="fname" name="fname" type="text"/></td>
<td><input id="lname" name="lname" type="text" /></td>
<td><input id="emailid" name="emailid" type="text" /></td>
client script
function filldata() {
var userid = gel('sys_display.emailadd').value;
var ga = new GlideAjax('GetUserParms');
ga.addParam('sysparm_name', 'getuserParms');
ga.addParam('sysparm_userid', userid.toString());
ga.getXML(useridCB);
}
function useridCB( response ) {
var answer = response.responseXML.documentElement.getAttribute("answer");
//g_form.addInfoMessage('answer is: ' + answer);
answer = answer.evalJSON();
}
i am able to get the value in answer variable. i have to store it in the above text field.
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-25-2017 06:15 AM
So when you get the result from the Ajax request just set the value either like
http://stackoverflow.com/questions/7609130/set-the-value-of-a-input-field-with-javascript#7609144
Or the jquery thing I wrote below

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-25-2017 03:44 AM
jQuery("#fname").val(yourfnamevar);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-25-2017 04:07 AM
can you pls elaborate?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-25-2017 06:15 AM
So when you get the result from the Ajax request just set the value either like
http://stackoverflow.com/questions/7609130/set-the-value-of-a-input-field-with-javascript#7609144
Or the jquery thing I wrote below

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-25-2017 09:57 AM
In the GlideAjax call back you need to use this
function filldata() {
var userid = gel('sys_display.emailadd').value;
var ga = new GlideAjax('GetUserParms');
ga.addParam('sysparm_name', 'getuserParms');
ga.addParam('sysparm_userid', userid.toString());
ga.getXML(useridCB);
}
function useridCB( response ) {
var answer = response.responseXML.documentElement.getAttribute("answer");
//g_form.addInfoMessage('answer is: ' + answer);
answer = answer.evalJSON();
$('fname').value=answer.fname;
$('lname').value=answer.lname;
$('emailid').value=answer.emailid;
}