Friday, May 17, 2024
 Popular · Latest · Hot · Upcoming
163
rated 0 times [  167] [ 4]  / answers: 1 / hits: 28067  / 12 Years ago, wed, october 24, 2012, 12:00:00

I'm writing some code in Oracle Apex and I don't come from a development background, so pardon my bad code. I'm dynamically generating a form and I want to set a hidden page item when the user changes the value of a specific form element. Here is the code I'm using:



    select APEX_ITEM.HIDDEN(2,base_data_seq_nbr)||APEX_ITEM.HIDDEN(6,case when substr(description,0,1)= chr(49838) then substr(description,-(length(description)-1)) else description end)||APEX_ITEM.HIDDEN(7,case when substr(description,0,1)= chr(49838) then 1 else 0 end)||APEX_ITEM.HIDDEN(9,
data_select(replace(replace(trim(substr(field_name,-(length(field_name)-instr(field_name,',',1)))),'BSBR',''),'C','L'), substr(field_name,0,instr(field_name,',',1)-1), :P721_XCASE,:P721_XRETSTAT,:P721_XID,:P721_XCUSNUM,:P721_DB_ID))||case when substr(description,0,1)= chr(49838)
then '<img src=/i/themes/theme_2/images/required.gif alt=Value Required alt=Value Required />'
else null
end as req_ind,
case when substr(description,0,1)= chr(49838)
then substr(description,-(length(description)-1))
else description
end as description,
APEX_ITEM.DATE_POPUP(1,rownum,
to_date(data_select(replace(replace(trim(substr(field_name,-(length(field_name)-instr(field_name,',',1)))),'BSBR',''),'C','L'), substr(field_name,0,instr(field_name,',',1)-1), :P721_XCASE,:P721_XRETSTAT,:P721_XID,:P721_XCUSNUM,:P721_DB_ID),'MM/DD/YYYY'),'MM/DD/YYYY',10,10,'onkeyup=javascript:FormatDate(this);' ||case when instr(substr(field_name,1,4),'DOB,',1)>0 then ' onchange=javascript:$s(''P721_DOB_RBD'',this);' end,'datepicker_'||rownum)
end
end as field_format
from bcvsown.bcvs_base_data
inner join v_lookup v
on v.value_seq = stmt_type
left join (select * from apex_collections where collection_name = 'ERR_COLLECTION') ac
on base_data_seq_nbr=ac.n001
where caseno = :P721_XCASE
and v.value_cd = case when :P721_XDE_SEQ > 1 then decode(:P721_XIS_BSRS,'true','BSRS','BET') else v.value_cd end
and db_id = :P721_DB_ID
and v.type_cd = 'STMT_TYPE'
order by base_data_seq_nbr


The page renders as expected with no error and the page source shows the javascript settings (onchange=javascript:$s(''P721_DOB_RBD'',this);) applied only to the elements I am aiming for. But when I change the element, it doesn't seem to set the value of the hidden page item (P721_DOB_RBD).


More From » oracle-apex

 Answers
37

No offense, that markup is quite horrible. Take the time to properly format and indent your code!


As for your problem, this is the Oracle apex javascript apis reference for $s



$s(pNd, pValue, pDisplayValue, pSuppressChangeEvent)

Given a DOM node or string ID (pNd), this function sets the
Application Express item value taking into account the item type. The
pDisplayValue is optional. If used for a page item of type "Popup LOV"
where the attribute "Input Field" = "Not Enterable, Show Display Value
and Store Return Value", it is used to set the "Input Field". The
value of pValue is stored in the hidden return field. The
pSuppressChangeEvent parameter is optional. Passing either FALSE or
not passing this parameter value results in a change event firing for
the item being set. Pass TRUE to prevent the change event from firing
for the item being set.


Parameters


pNd (DOM Node | string ID)
pValue (String | Array)
pDisplayValue(String)
pSuppressChangeEvent(Boolean)


Passing on this won't work. That will pass on the object, when you want to pass on a value. Since you're creating a APEX_ITEM.DATE_POPUP which will generate an input item, you will need the value of the item at the time the change event happens. You can do that by using $v (ref)



$v(pNd)

Given a DOM node or string ID (pNd), this function returns the value
of an Application Express item in the same format as it would be
posted.


Parameters


pNd (DOM Node | string ID)


So, try with this:


(onchange="javascript:$s(''P721_DOB_RBD'',$v(this));")

[#82374] Tuesday, October 23, 2012, 12 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
shekinah

Total Points: 699
Total Questions: 112
Total Answers: 110

Location: Philippines
Member since Sat, Jul 11, 2020
4 Years ago
;