Using AJAX to populate form fields
Hello All,
My problem is, I have a form containing id,first_name,middle_name,las_name,........
I want to use AJAX, such that when the user entered the ID, the other fields
populated automatically.
I used the method described in this link
http://www.oracle.com/technology/obe/hol08/apexweb20/ajax_otn.htm
it works fine for one field (i.e. when the user enterd the ID the first_name fields populated).
my question is how can I populate the other fields using one and only one process,
where is the part of the code that I need to modify.
here is my work:
The application process is get_info:
-- =============================
DECLARE
l_counter number;
l_o_name varchar2(2000);
l_national_id varchar2(4000);
BEGIN
l_national_id := wwv_flow.g_x05;
owa_util.mime_header('text/xml', FALSE );
htp.p('Cache-Control: no-cache');
htp.p('Pragma: no-cache');
owa_util.http_header_close;
htp.prn('<select>');
FOR rec IN (
select ID, first_name from vote_name where ID = l_national_id )
LOOP
htp.prn('<option value="' || rec.ID|| '">' ||rec.first_name
|| '</option>');
END LOOP;
htp.prn('</select>');
END;
-- =======================================
-- page HTML header
<script type="text/javascript">
function get_AJAX_SELECT_XML_ELECT_CIRCLE(pThis,pName1){
var l_Return = null;
var l_Select = $x(pName1);
var get = new htmldb_Get(null,$v('pFlowId'),
'APPLICATION_PROCESS=get_info',0);
get.addParam('x05',$v(pThis));
gReturn = get.get('XML');
if(gReturn && l_Select){
var l_Count = gReturn.getElementsByTagName("option").length;
l_Select.length = 0;
for(var i=0;i<l_Count;i++){
var l_Opt_Xml = gReturn.getElementsByTagName("option");
appendToSelect(l_Select, l_Opt_Xml.getAttribute('value'),
l_Opt_Xml.firstChild.nodeValue)
}
}
get = null;
}
function appendToSelect(pName1, pValue, pContent) {
var l_Opt = document.createElement("option");
l_Opt.value = pValue;
if(document.all){
pName1.options.add(l_Opt);
l_Opt.innerText = pContent;
}else{
l_Opt.appendChild(document.createTextNode(pContent));
pName1.appendChild(l_Opt);
}
}
</script>
any idea please