Select, Radio form echo features avoid using jquery to load assignment _javascript tips

Source: Internet
Author: User
Select,radio form Echo Avoid using jquery to load assignments
Precautions :
Copy Code code as follows:

<body>
<form method= "POST" action= "" >
<!--It is not recommended to use the following code if the Reset feature is used in the form-->
<input type= "Radio" name= "Visible" value= "1"/> Show <br>
<input type= "Radio" name= "visible" value= "0"/> Hidden <br>
<select name= "by" id= "by" >
<option value= "0" >0</option>
<option value= "1" >1</option>
</select><br>
<input type= "Reset" >
</form>
</body>

Not recommended: Use the following JS code
Copy Code code as follows:

<script type= "Text/javascript" >
<!--
$ (function () {
Echo is not really the default value for data
$ ("input[type=radio][name=visible]"). each (function () {
if ($ (this). val () = = ' ${teacher.visible} ') {
$ (this). attr ("Checked", "checked");
}
});
$ ("#orderBy option"). each (function () {
if ($ (this). val () = = ' ${teacher.orderby} ') {
$ (this). attr ("Selected", "Selected");
}
});
});
-->
</script>

The best way to do this is to make logical judgments on JSP pages
Copy Code code as follows:

<!--recommended to use the following code-->
<input type= "Radio" name= "Visible" value= "1" <c:if test= "${teacher.visible==1}" >checked= "Checked" </c:if>/> show <br>
<input type= " Radio "name=" visible "value=" 0 "<c:if test=" ${teacher.visible==0} ">checked=" checked "</c:if>/> Hide < Br>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.