4)
在页面加一个html项目,内容如下:
<script. language="javascript">
//全局变量
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<namespace>.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<namespace>.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<namespace>.promptAction('finish')
}
}
//页面初始加载
document.forms[0].onload=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<buttons.length; i++)
{
if (buttons.id.indexOf('finish') == 0) // The finish button ID starts with finish. ie: id="finishN0D5D2148x0C6BEFD0_NS_"
{
if (buttons.onclick.toString().indexOf('finish') > 0) //oCV_NS_.promptAction('finish')
{
//buttons.onclick = ValidatePage;
buttons.style.display="none";
}
}
}
//设置onchange事件
getSpanInfo()
selectYear[0].onchange=validateSelectYear;
selectStation[0].onchange=validateSelectStation;
selectVoltage[0].onchange=validateSelectVoltage;
</script>