Copy code The code is as follows:<span style="font-family:Microsoft YaHei;"><select id="lstTest" onfocus="this.defaultIndex=this.selectedIndex;" onchange="this.selectedIndex=this.defaultIndex;"> <option value="1">test1</option> <option value="2">test2</option> <option value="3" selected="selected">test3</option> <option value="4">test4</option> <option value="5">test5</option> </select> </span> 1》Problem of setting the readonly attribute of the form: However, the readonly attribute has no effect on the three forms of radio, select, and checkbox 2》Set the disabled attribute of the form Problem: After setting the disabled attribute, the background cannot read data way: 1. Set the disabled attribute and store the form value in the hidden field 2. Use jQuery to control (set the form attribute disabled=true when loading the page, and set the form attribute disabled=false when submitting the form) Code: Reference jquery file <script type="text/javascript" src="../../js/jquery-1.3.2.js"></script> Controlling the disabled attribute with scripts Copy code The code is as follows:<span style="font-family:Microsoft YaHei;"><script type="text/javascript"> //Set disabled to take effect when loading $(document).ready(function(){ $("input[name=category]").attr("disabled",true); $("select[name=sonota_kbn]").attr("disabled",true); }); //Set disabled to fail when submitting $("input[name=modify]").click(function(){ $("input[name=category]").attr("disabled",false); $("select[name=sonota_kbn]").attr("disabled",false); }); </script> </span> Note this: input[name=category] Input is the form type (for example, select is a drop-down box) name=category The name of the form |
<<: CSS float (float, clear) popular explanation and experience sharing
Introduction react-i18next is a powerful internat...
1. First install the pagoda Installation requirem...
Preface: Integer is one of the most commonly used...
What should I do if MySQL fails to connect to the...
Scenario 1. Maintain a citizen system with a fiel...
Table of contents 1. What is recursion? 2. Solve ...
The latest Perfect Aloe Vera Gel packaging box ha...
Preface The reason why MySQL's innodb engine ...
This article shares the specific code of Vue to a...
After watching this, I guarantee that you have ha...
Copy code The code is as follows: li {width:300px...
Autotrash is a command line program that automate...
Table of contents 1. Analysis of MySQL architectu...
Here are some examples of how I use this property ...
1.command not found command not found 2. No such ...