AJAX with two variables and hidden item...
dmcghanSep 20 2006 — edited Sep 20 2006Hello everyone,
I'm trying to use Carls original AJAX function and add on a little bit. I have a query that uses to variables and not just one. The value of the variable is stored in TEMPORARY_ITEM and TEMPORARY_ITEM2. For some reason I can get the value of the first to work, but not the second, which gets it's value from a hidden item. The code is as follows:
Call:
onchange="get_SEL_ALEV(this,'P53_GATP_JBTT_ID','P56_GALV_ALEV_ID')"
Javascript:
<script language="JavaScript1.1" type="text/javascript">
function get_SEL_ALEV(pThis,pTempx,pSelect){
if (pThis.value !== '0123456789') {
var l_Return = null;
var l_Select = html_GetElement(pSelect);
var get = new htmldb_Get(null,html_GetElement('pFlowId').value,'APPLICATION_PROCESS=SEL_ALEV_FLTR_CUR_GRT',0);
get.add('TEMPORARY_ITEM',pThis.value);
get.add('TEMPORARY_ITEM2',pTempx.value);
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;
} else {
var l_Return = null;
var l_Select = html_GetElement(pSelect);
var get = new htmldb_Get(null,html_GetElement('pFlowId').value,'APPLICATION_PROCESS=SEL_ALEV_NULL',0);
get.add('TEMPORARY_ITEM',pThis.value);
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")[i];
appendToSelect(l_Select, l_Opt_Xml.getAttribute('value'), l_Opt_Xml.firstChild.nodeValue)
}
}
get = null;
}
}
function appendToSelect(pSelect, pValue, pContent) {
var l_Opt = document.createElement("option");
l_Opt.value = pValue;
if(document.all){/* why is ie different ask bill */
pSelect.options.add(l_Opt);
l_Opt.innerText = pContent;
}else{
l_Opt.appendChild(document.createTextNode(pContent));
pSelect.appendChild(l_Opt);
}
}
</script>
Process:
declare
l_counter number;
l_o_name varchar2(2000);
begin
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 NULL as id,
'- Select Access Level -' as title
from dual
UNION
SELECT alev_id AS id,
alev_title AS title
FROM acc_levels
JOIN acc_types
ON alev_atyp_id = atyp_id
WHERE alev_atyp_id = :TEMPORARY_ITEM
AND alev_id NOT IN (
SELECT galv_alev_id
FROM grt_acc_levels
WHERE galv_jbtt_id = :TEMPORARY_ITEM2)
ORDER BY 2)
loop
htp.prn('<option value="' || rec.id || '">' || rec.title || '</option>');
end loop;
htp.prn('</select>');
end;
The second variable is used to filter the results of the query to avoid unnecessary options that would produce duplicates. As I try to change the code around I always get all the options as thought TEMPORARY_ITEM2 is null, or I get no options at all. Any help would be great.