一段逻辑性很强的脚本语言
谁能简单的帮我注释下?
function getState()
{
var whichleave1=document.getElementById( "leavehidden1 ").value;
var orderid=document.getElementById( "orderid1 ").value;
var arrive= " ";
var leave= " ";
if(whichleave1==0)
{
leave=document.getElementById( "leave11 ").value;
}
if(whichleave1==1)
{
leave=document.getElementById( "leave12 ").value;
}
var whicharrive1=document.getElementById( "arrivehidden1 ").value;
if(whicharrive1==0)
{
arrive=document.getElementById( "arrive11 ").value;
}
if(whicharrive1==1)
{
arrive=document.getElementById( "arrive12 ").value;
}
if(leave==0&&arrive==1)
{
alert( "尚未出发,不可能完成! ");
document.location.href= "searchOrder.jsp ";
}
else document.location.href= "modiState.jsp?leave= "+leave+ "&arrive= "+arrive+ "&orderid= "+orderid;
}
function getState2(i)
{
var whichleave2=document.getElementById( "leavehidden2 "+i).value;
var orderid=document.getElementById( "orderid2 "+i).value;
var arrive= " ";
var leave= " ";
if(whichleave2==0)
{
leave=document.getElementById( "leave21 "+i).value;
//leave=document.getElementById( "leave213 ").value;
//alert(leave);
}
if(whichleave2==1)
{
leave=document.getElementById( "leave22 "+i).value;
//alert(i);
}
var whicharrive2=document.getElementById( "arrivehidden2 "+i).value;
if(whicharrive2==0)
{
//alert(i);
arrive=document.getElementById( "arrive21 "+i).value;
//arrive=document.getElementById( "arrive213 ").value;
//alert(arrive);
}
if(whicharrive2==1)
{
arrive=document.getElementById( "arrive22 "+i).value;
// alert(arrive);
}
if(leave==0&&arrive==1)
{
alert( "尚未出发,不可能完成! ");
document.location.href= "searchOrder.jsp ";
}
else document.location.href= "modiState.jsp?leave= "+leave+ "&arrive= "+arrive+ "&orderid= "+orderid;
}
</script>
------解决方案--------------------看了一看,给你几个关键的注释,剩下的LZ自己努力一把
getElementById // 根据页面元素的ID,找到这个元素
getElementById(XXX).value // 根据页面元素的ID,找到这个元素的value属性包含的值
document.location.href // 给页面重定向到一个地址.
------解决方案--------------------要有耐心
------解决方案--------------------受用