javascript 选择 。动态爱情,级联爱情
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了javascript 选择 。动态爱情,级联爱情相关的知识,希望对你有一定的参考价值。
function onChangeBrandGetShips(e){
var selected_val = '';
var brand = $(e.triggeringElement).parent().parent().find('select[name="f03"]').val();
var set_list = $(e.triggeringElement).parent().parent().find('select[name="f04"]');
var row_id = $(e.triggeringElement).parent().parent().find('input[name="f02"]').val();
apex.server.process (
"GET_SHIPS",
{
x01: brand,
x02: row_id
},
{
success: function( pData ) {
$(set_list).find('option').remove();
$.each(pData, function(key, innerjson) {
$(set_list).append($('<option>', {
value: innerjson.VALUE,
text: innerjson.NAME
}));
if (innerjson.SELECTED !== '') {selected_val = innerjson.SELECTED};
});
// if found selected value
if (selected_val !== '') {
$(set_list).find('option')
.each(function()
{
this.selected = (this.text == selected_val);
}
);
}
},
}
);
}
DECLARE
l_param VARCHAR2 (40) := apex_application.g_x01;
l_row_id VARCHAR2 (40) := apex_application.g_x02;
l_list VARCHAR2 (4000) := '{"KEY0": {"NAME":"- Select -","VALUE":"","SELECTED":""},';
l_selected_value varchar2 (200);
v_count NUMBER := 1;
BEGIN
if l_row_id is not null then
begin
select ship
into l_selected_value
from lgms_frt_plan_dd
where lgms_frt_plan_dd_id = l_row_id;
exception when others then
l_selected_value := null;
end;
end if;
FOR c IN (select item_shtname
, item_code
from lgms_lov_v
where upper(lov_code) = 'SHIPS'
and attribute3 = l_param -- 'PCL'
order by 1)
LOOP
l_list :=
l_list
|| '"KEY' || v_count
|| '":{"NAME":"' || c.item_shtname
|| '","VALUE":"' || c.item_code
|| '","SELECTED":"' || CASE WHEN c.item_code = l_selected_value
THEN c.item_shtname
ELSE NULL
END
|| '"},';
v_count := v_count + 1;
END LOOP;
l_list := RTRIM (l_list, ',');
l_list := l_list || '}';
HTP.p (l_list);
END;
1. Dynamic Action on Change of jQuery Selector select[name="f03"] - runs on page load - is:
var elem = '#' + this.triggeringElement.id;
var key = '#' + 'f02_' + this.triggeringElement.id.substring(4);
var set_list = '#' + 'f04_' + this.triggeringElement.id.substring(4);
var key_val = $(key).val();
var elem_val = $(elem).val();
var selected_val = '';
apex.server.process (
"getEmployees",
{
x01: elem_val,
x02: key_val
},
{
success: function( pData ) {
$(set_list).find('option').remove();
$.each(pData, function(key, innerjson) {
$(set_list).append($('<option>', {
value: innerjson.VALUE,
text: innerjson.NAME
}))
if (innerjson.SELECTED != '') {selected_val = innerjson.SELECTED};
});
if (selected_val != '') {
$('select' + set_list + ' option').each(function()
{this.selected = (this.text == selected_val);});
}
},
}
);
2. On Demand Process "getEmployees" - gets the employes of the selected department + selected values for an existing record:
DECLARE
v_deptno VARCHAR2 (40) := TO_NUMBER (apex_application.g_x01);
v_id VARCHAR2 (40) := TO_NUMBER (apex_application.g_x02);
v_ename VARCHAR2 (4000) := '{"KEY0": {"NAME":"- Select Employee -","VALUE":"","SELECTED":""},';
v_selected_empno VARCHAR2 (40);
v_count NUMBER := 1;
BEGIN
IF v_id IS NOT NULL
THEN
SELECT empno
INTO v_selected_empno
FROM emp_log
WHERE ID = v_id;
END IF;
FOR c IN (SELECT ename, empno
FROM emp
WHERE deptno = v_deptno)
LOOP
v_ename :=
v_ename
|| '"KEY'
|| v_count
|| '":{"NAME":"'
|| c.ename
|| '","VALUE":"'
|| c.empno
|| '","SELECTED":"'
|| CASE
WHEN c.empno = v_selected_empno
THEN c.ename
ELSE NULL
END
|| '"},';
v_count := v_count + 1;
END LOOP;
v_ename := RTRIM (v_ename, ',');
v_ename := v_ename || '}';
HTP.p (v_ename);
END;
3. Employee Select List Query is:
SELECT NULL d, NULL r
FROM DUAL
WHERE 1 = 2
4. Dynamic Action on Change of jQuery Selector select[name="f03"] - runs on change:
var elem = '#' + this.triggeringElement.id;
var key = '#' + 'f02_' + this.triggeringElement.id.substring(4);
var set_list = '#' + 'f04_' + this.triggeringElement.id.substring(4);
var key_val = $(key).val();
var elem_val = $(elem).val();
var selected_val = '';
apex.server.process (
"getEmployees",
{
x01: elem_val,
x02: key_val
},
{
success: function( pData ) {
$(set_list).find('option').remove();
$.each(pData, function(key, innerjson) {
$(set_list).append($('<option>', {
value: innerjson.VALUE,
text: innerjson.NAME
}))
if (innerjson.SELECTED != '') {selected_val = innerjson.SELECTED};
});
if (selected_val != '') {
$('select' + set_list + ' option').each(function()
{this.selected = (this.text == selected_val);});
}
},
}
);
以上是关于javascript 选择 。动态爱情,级联爱情的主要内容,如果未能解决你的问题,请参考以下文章