实现功能说明:
1)登陆后设置提示第一个有效值为默认值;2)实现自动提交
(模拟自动提交);3)仅能选择一个有效提示值,即选择数据项名称和‘-------’无效。
实现方法:
1) 在下值提示前后各加一个html项目,
内容分别为:
与
注意:span id内容根据实际设置。如附件图片“值提示”。
此例中,我共有3个值提示,其中电压等级与站是级联关系,电压等级层级高于站:
年份提示
站提示
电压等级提示
2) 添加一个完成按钮。(此按钮最终会被隐藏,代码控制其提交)
3) 将所有提示的自动提交取消!
4)
在页面加一个html项目,内容如下:
//全局变量
var spanYear;
var selectYear;
var selectIndexYear;
var spanStation;
var selectStation
var selectIndexStation;
var spanVoltage;
var selectVoltage;
var selectIndexVoltage;
//获取页面值提示对象
function getSpanInfo(){
spanYear = document.getElementById("spanidYear");//The same name as the span id.set for year prompt
selectYear = spanYear.getElementsByTagName("select");
selectIndexYear=selectYear[0].selectedIndex;
spanStation = document.getElementById("spanidStation");//The same name as the span id.set for station prompt
selectStation = spanStation.getElementsByTagName("select");
selectIndexStation=selectStation[0].selectedIndex;
spanVoltage = document.getElementById("spanidVoltage");//The same name as the span id.set for voltage prompt
selectVoltage = spanVoltage.getElementsByTagName("select");
selectIndexVoltage=selectVoltage[0].selectedIndex;
}
//初始化页面
function initOnLoad()
{
getSpanInfo();
if(selectIndexYear==0||selectIndexYear==1)
{ selectVoltage[0].selectedIndex=2;
selectYear[0].selectedIndex=2;
//selectStation[0].selectedIndex=2;
if(getFormWarpRequest().elements["cv.id"].value=="RS")
{
setTimeout('oCVRS.promptAction(\'finish\')',100); //延迟一定时间很重要,否则会报错
}else
setTimeout('oCV_NS_.promptAction(\'finish\')',100);
}
}
//年提示值变化(onchange事件)调用
function validateSelectYear()
{ getSpanInfo();
if (selectIndexYear==0 || selectIndexYear==1){
//no response
}
else
{
promptButtonFinish(); // Currently equivalent to oCV.promptAction('finish')
}
}
//站提示值变化(onchange事件)调用
function validateSelectStation()
{ getSpanInfo();
if (selectIndexStation==0 || selectIndexStation==1){
//no response
}
else
{
if(selectIndexYear ==0 || selectIndexYear ==1){
selectYear[0].selectedIndex=2;
}
promptButtonFinish(); // Currently equivalent to oCV.promptAction('finish')
}
}
//电压等级提示值变化(onchange事件)调用
function validateSelectVoltage()
{ getSpanInfo();
if (selectIndexVoltage==0 || selectIndexVoltage==1){
//no response
}
else
{
if(selectIndexYear ==0 || selectIndexYear ==1){
selectYear[0].selectedIndex=2;
}
if(selectIndexStation!=0 && selectIndexStation!=1){
selectStation[0].selectedIndex=0;
}
promptButtonFinish(); // Currently equivalent to oCV.promptAction('finish')
}
}
//页面初始加载
document.forms[0].οnlοad=initOnLoad();
var fW = (typeof getFormWarpRequest == "function" ?getFormWarpRequest() : document.forms["formWarpRequest"]);
if ( !fW || fW == undefined)
{
fW = ( formWarpRequest_THIS_ ?formWarpRequest_THIS_ : formWarpRequest_NS_ );
}
var buttons = fW.getElementsByTagName("BUTTON");
for (var i=0; i
{
if (buttons[i].id.indexOf('finish') == 0) // The finish button ID starts with finish. ie: id="finishN0D5D2148x0C6BEFD0_NS_"
{
if (buttons[i].onclick.toString().indexOf('finish') > 0) //oCV_NS_.promptAction('finish')
{
//buttons[i].onclick = ValidatePage;
buttons[i].style.display="none";
}
}
}
//设置onchange事件
getSpanInfo()
selectYear[0].οnchange=validateSelectYear;
selectStation[0].οnchange=validateSelectStation;
selectVoltage[0].οnchange=validateSelectVoltage;
prompt.jpg
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/21947683/viewspace-620233/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/21947683/viewspace-620233/