0

我有三个字段 ForteID、disposition 和 Cancel_Disposition。现在我的javascript中有这段代码,它可以工作:

function validateForteID(){
  if(document.csform.ForteID.selectedIndex==0)
  {
    alert("Please select your Forte ID.");
    document.csform.ForteID.focus();
    return false;
  }
  if(document.csform.disposition.selectedIndex==0)
  {
    alert("Please select a disposition.");
    document.csform.disposition.focus();
    return false;
  }
  if(document.csform.Cancel_Disposition.selectedIndex==0)
  {
    alert("Please select a disposition.");
    document.csform.Cancel_Disposition.focus();
    return false;
  }
  return true;
}

我想要做什么但不完全确定如何去做,但如果字段 Disposition 是 LOC 或 Backout,那么我希望它执行这部分代码:

if(document.csform.Cancel_Disposition.selectedIndex==0)
{
  alert("Please select a disposition.");
  document.csform.Cancel_Disposition.focus();
  return false;
}

但前提是处置是 LOC 或 Backout。如果我需要更多解释,请告诉我,提前致谢!

4

1 回答 1

0
var cancel_disposition_value = document.csform.Cancel_Disposition[document.csform.Cancel_Disposition.selectedIndex].value;
if(cancel_disposition_value=='LOC' || cancel_disposition_value=='Backout')
{
    alert("Please select a disposition.");
    document.csform.Cancel_Disposition.focus();
    return false;
}
于 2012-12-14T23:23:46.840 回答