分类: 系统运维
2011-01-06 10:56:08
实现功能说明:
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
}
}
//站提示值变化(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
}
}
//电压等级提示值变化(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
}
}
//页面初始加载
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
{
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].onchange=validateSelectYear;
selectStation[0].onchange=validateSelectStation;
selectVoltage[0].onchange=validateSelectVoltage;
chinaunix网友2011-01-12 10:19:09
var form = getFormWarpRequest(); var listAdd = form._oLstChoices_ListboxAdd;//_ListboxAdd下拉框名字 listAdd.remove(1); listAdd.remove(0); listAdd.removeAttribute("hasLabel"); //这里为了取消虚线和参数标题 listAdd.options[listAdd.length].selected=true;//选中一个值 var isOption = listAdd.length; isOption = parseInt(isOption); if(isOption==1){ canSubmitPrompt(); //自动提交 if (getFormWarpRequest().elements["cv.id"].value == "RS"){ setTimeout('oCVRS.promptA
chinaunix网友2011-01-07 16:53:19
很好的, 收藏了 推荐一个博客,提供很多免费软件编程电子书下载: http://free-ebooks.appspot.com