JS obtains the values before the select change event onchage and The onclick event.
<Select id = "wupin_id" name = "wupin_id" onclick = "savelast ()" onchange = "changeform (this. Value)">
<Option value = "0" selected> select the device type you want to use </option>
<Option value = "001"> HP scanner g5590 </option>
<Option value = "002"> HP scanner g2410 </option>
<Option value = "003"> HP scanner g3110 </option>
</SELECT>
<SCRIPT>
VaR lastindex, lastvalue;
Function savelast (){
VaR select = Document. getelementbyid ("wupin_id ");
Lastindex = select. selectedindex;
VaR midvalue = select. Options [lastindex]. value;
// Var text = select. Options [Index]. text;
If (midvalue! = "0 "){
Lastindex = select. selectedindex;
Lastvalue = select. Options [lastindex]. value;
}
}
Application:
Function changeform (VAL ){
VaR OBJ = Document. getelementbyid ("wupin_id ");
VaR tr01 = Document. getelementbyid ("tr01"). value;
VaR flag = Document. getelementbyid ("saverk"). Disabled;
VaR flag2 = Document. getelementbyid ("tr01"). Disabled;
If (Val! = "0" & flag2 = true ){
Document. getelementbyid ("tr01"). Disabled = false;
Document. getelementbyid ("tr01"). Focus ();
}
If (Val! = "0" & tr01! = "" & Flag! = True ){
Alert ("please save the data to the database first, and then scan and enter other types of items! ");
OBJ. Options [lastindex]. Selected = true; // load the user to change the previously selected value
Document. getelementbyid ("saverk"). Focus ();
}
}