JS实现自动级联提示而不刷新页面Word格式文档下载.docx
- 文档编号:16544479
- 上传时间:2022-11-24
- 格式:DOCX
- 页数:11
- 大小:58.74KB
JS实现自动级联提示而不刷新页面Word格式文档下载.docx
《JS实现自动级联提示而不刷新页面Word格式文档下载.docx》由会员分享,可在线阅读,更多相关《JS实现自动级联提示而不刷新页面Word格式文档下载.docx(11页珍藏版)》请在冰豆网上搜索。
Copy下面的代码到右面的HTML项目中:
/div>
script>
//------------------------------------getcognosrequestobject----------------------
varfW=(typeofgetFormWarpRequest=="
function"
?
getFormWarpRequest():
document.forms["
formWarpRequest"
]);
if(!
fW||fW==undefined){fW=(formWarpRequest_THIS_?
formWarpRequest_THIS_:
formWarpRequest_NS_);
}
//------------------------------------getAllPromptNames----------------------
functiongetAllPromptNames()
{
varaPromptNames=newArray();
for(variinwindow){
if(("
"
+i).match(/^listBox/)){
varsName=i.replace(/^listBox/,"
);
aPromptNames.push(sName);
elseif(("
+i).match(/^radioList/)){
varsName=i;
+i).match(/^checkBoxList/)){
returnaPromptNames;
//-----------------------------------toavoidMemoryLeak----
i=null;
sName=null
//hidingselectAll/deselectAll
for(j=0;
j<
document.links.length;
j++)
y=document.links[j];
if(y.id.indexOf("
SELECT"
)!
=-1)document.getElementById(y.id).style.display='
None'
;
String.prototype.trim=function(){
returnthis.replace(/^\s+|\s+$/g,"
);
fW._oLstChoicesPN_ProductLine.onchange=function()
{cascadePrompts("
ProductLine"
"
ProductType,Product"
)};
fW._oLstChoicesPN_ProductType.onchange=function()
ProductType"
Product"
//Checkifthepromptsbeingcascadedarepresent
//onpageorremovedasperreportrequirement
functionvalidatePrompts(removearr)
promptsonpage=getAllPromptNames();
varflag;
newarr=newArray();
vari=0;
for(varj=0;
j<
removearr.length;
j++)
{
flag=false;
for(varjj=0;
jj<
promptsonpage.length;
jj++){
if(("
PN_"
+removearr[j])==promptsonpage[jj])
{
flag=true;
break;
}
}
if(flag==true)
{
newarr[i]=removearr[j];
i++;
}
}
returnnewarr;
//callsallthefunctionsrequiredforcascadeing
//prompt:
Listpromptonwhichhasthevaluestofilterthechildprompts
//remove:
Childpromptsonwhichthecascadingissupposedtobeperformed
functioncascadePrompts(prompt,remove){
removearr=newArray();
removearr=remove.split("
newarray=validatePrompts(removearr);
emptyList(newarray);
createList(prompt,newarray);
//Emptychildpromptsbeforeyouinsertnewfilteredvalues
functionemptyList(arr){
for(varjj=0;
arr.length;
fW["
_oLstChoicesPN_"
+arr[jj]].selectedIndex=-1;
+arr[jj]].length=0;
}
//------------------toavoidmemoryleak-----
arr=null;
//createsthefilterarray
functioncreateList(prompt,newarr){
varlen2=fW["
+prompt].length;
arrfilter=newArray();
varidx=0;
for(varj=0;
len2;
j++){
if(fW["
+prompt][j].selected==true){
arrfilter[idx]=fW["
+prompt][j].value;
idx++;
}
newarr.length;
jj++)
{
createListFilter(prompt,newarr[jj],arrfilter);
//------------------toavoidmemoryleak-----
arrfilter=null;
newarr=null;
functioncreateParentFilter(prompt)
varlen2=fW["
+prompt].length;
varfilter=newArray();
filter[idx]=fW["
+prompt][j].value;
returnfilter;
functioncheckParentFilter(string,fltr,flg)
for(vark=0;
k<
fltr.length;
k++)
if(fltr[k]!
="
All"
&
&
flg){
if(string.match(fltr[k]))
{
returntrue;
}
}
else{returnflg;
}if(fltr.length==0){returntrue;
flg=false;
returnflg;
}
functioncreateListFilter(filterlevel,filtervalues,filter){
varparFiltersStr="
ProductLine,ProductType"
parentarr=newArray();
parentarr=parFiltersStr.split("
newParentArr=validatePrompts(parentarr);
parentFilterStr=newParentArr.join();
ProductLinefilter=newArray();
if(parentFilterStr.match("
)){
ProductLinefilter=createParentFilter("
else{
ProductLinefilter[0]="
//-------------------------ProductLinefilters---
ProductTypefilter=newArray();
ProductTypefilter=createParentFilter("
ProductTypefilter[0]="
//-------------------------ProductTypefilters---
varfd;
varsd;
vartd;
varfrd;
vartdidx=0;
varfdidx=0;
varsdidx;
varfrdidx;
arr=newArray();
if(filterlevel=="
){
fd="
sd="
~"
if(filterlevel=="
#"
^"
//----------------------------------filterValues------------------------------
if(filtervalues=="
td="
frd="
if(filtervalues=="
}
varlen=fW._oLstChoicesPN_ConcatString.length;
for(varidx=0;
idx<
filter.length;
idx++){
for(vari=0;
i<
len;
i++){
varstring2=fW._oLstChoicesPN_ConcatString[i].value;
fdidx=string2.indexOf(fd);
sdidx=string2.indexOf(sd);
tdidx=string2.indexOf(td);
frdidx=string2.indexOf(frd);
varstring3=string2.substring(fdidx+1,sdidx);
if(filter[idx]!
="
){
if(string3.trim()==filter[idx].trim()){
varflag=true;
flag=checkParentFilter(string2,ProductLinefilter,flag);
flag=checkParentFilter(string2,ProductTypefilter,flag);
if(flag)
arr[i]=string2.substring(tdidx+1,frdidx);
}
else{
arr=uniqueVal(arr);
filtervalues="
+filtervalues;
for(varj=0;
if(arr[j]!
=undefined&
arr[j]!
=null&
varelOptNew=document.createElement('
option'
elOptNew.text=arr[j];
elOptNew.value=arr[j];
fW[filtervalues].add(elOptNew);
regionfilter=null;
countryfilter=null;
filter=null;
string2=null;
functionuniqueVal(oldarr){
oldarr.sort();
j=0;
newarr=newArray()
for(vari=0;
i<
oldarr.length;
i++){
newarr[j]=oldarr[i];
j++;
if((i>
0)&
(oldarr[i]==oldarr[i-1])){
newarr.pop();
j--
returnnewarr;
/script>
7.保存运行报表,查看效果。
将自动级联扩展到更多值提示的步骤
1.在右面的HTML项代码中,需要为新的提示添加‘onchange’事件,并需要为该提示传递子提示的名称。
2.需要为提示的每个层次修改parFiltersStr变量。
同样还需要创建新的数组。
3.还需要对隐藏提示使用哪个级联功能的查询(当前示例中使用的是查询5)进行修改。
还需要在查询中添加一列,并加上分隔符。
还需要按照查询中定义的分隔符修改/添加if条件句中的过滤级和过滤值。
4.还需要添加检查父提示值的情形,如代码“flag=checkParentFilter(string2,ProductLinefilter,flag);
”所示。
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- JS 实现 自动 级联 提示 刷新 页面
![提示](https://static.bdocx.com/images/bang_tan.gif)