Today involves a problem, in the query criteria in the JSP, there are text boxes to enter filter criteria, there are drop-down boxes to select the filter criteria. The contents of the input box can be deleted by pressing the "Backspace" key, but the Backspace function needs to be shielded in the dropdown box, otherwise the rollback function of the page is performed. The code is as follows
Copy Code code as follows:
<TD width= "350px;" > Company Name:
<input type= "text" name= "Filter_psname" id= "Psname" size= "the/>"
</td>
<TD width= "200px;" > Area:
<select name= "Filter_regioncode" id= "Regionname" theme= "simple"/>
</td>
<td>
<s:radio onclick= "query ()" Name= "Filter_status" theme= "simple" ></s:radio>
</td>
<TD valign= "Middle" align= "center" >
</td>
Find a section of the Internet screen backspace code as follows
Copy Code code as follows:
$ (document). KeyDown (function (e) {
var doprevent;
if (E.keycode = = 8) {
var d = E.srcelement | | E.target;
if (d.tagname.touppercase () = = ' SELECT ') {
doprevent = D.readonly | | d.disabled;
}
Else
Doprevent = true;
}
Else
Doprevent = false;
if (doprevent)
E.preventdefault ();
});
The following questions were found:
The Drop-down box D.tagname gets the label name also input. Therefore can not achieve the above demand.
After a careful study, the following code
Copy Code code as follows:
The BACKSPACE key operation of the screened dropdown box
$ (document). KeyDown (function (e)
{
Get key code for keyboard
var K=e.keycode;
Gets the label object for the operation
var Obj=e.target | | E.srcelement;
Gets the value of the read-only property of an object
var vreadonly = Obj.getattribute (' readonly ');
Return FALSE if the key is "backspace" and the label object's read-only property is not empty (select label default readonly= "ReadOnly")
if (k==8 && vreadonly!=null) {
return false;
}
});
To achieve the above needs, there should be a better way, I hope friends see can give tips or talk to each other.