<script>
function alertMsg(Obj,Id)
{
if(Obj.selectedIndex=="3")
{
if(confirm("设置为无效订单后,此订单将不可再操作"))
{
window.location.href="?sate="+Obj.selectedIndex+"&orderId="+Id;
}
else
{
Obj.selectedIndex=0;  //放弃选择让option 还原
return;
}
}else
{
window.location.href="?sate="+Obj.selectedIndex+"&orderId="+Id;
}
}
</script>这段代码如何改进一下
我不想出现两次 window.location.href="?sate="+Obj.selectedIndex+"&orderId="+Id;

解决方案 »

  1.   

    function alertMsg(Obj,Id)
    {
    if(Obj.selectedIndex=="3") && (!(confirm("设置为无效订单后,此订单将不可再操作")))
    {
    if(confirm("设置为无效订单后,此订单将不可再操作"))
    {
     
    Obj.selectedIndex=0;  //放弃选择让option 还原
    return;
     
    }
    else
    {
    window.location.href="?sate="+Obj.selectedIndex+"&orderId="+Id;
    }
      

  2.   

    弄错了,改下function alertMsg(Obj,Id)
    {
    if(Obj.selectedIndex=="3") && (!(confirm("设置为无效订单后,此订单将不可再操作")))
    {
    Obj.selectedIndex=0;  //放弃选择让option 还原
    return;
    }
    else
    {
    window.location.href="?sate="+Obj.selectedIndex+"&orderId="+Id;
    }
    }
      

  3.   


    <script> 
    function alertMsg(Obj,Id) 

    if(Obj.selectedIndex=="3") 

    if(confirm("设置为无效订单后,此订单将不可再操作")) 

    window.location.href="?sate="+Obj.selectedIndex+"&orderId="+Id;
    return;

    else 

    Obj.selectedIndex=0;  //放弃选择让option 还原 
    return; 

    }
    else 

    window.location.href="?sate="+Obj.selectedIndex+"&orderId="+Id; 


    </script>