select, radio form echo avoids jquery loading assignment
Notes:
<html>
<body>
<form method="post" action="">
<!-- If the reset function is used in the form, the following code is not recommended -->
<input type="radio" name="visible" value="1" />Show<br>
<input type="radio" name="visible" value="0" />Hide<br>
<select name="orderBy" >
<option value="0">0</option>
<option value="1">1</option>
</select><br>
<input type="reset">
</form>
</body>
</html>
Not recommended: Use the following js code
<script type="text/javascript">
<!--
$(function(){
//It is not the default value of the data when echoing
$("input[type=radio][name=visible]").each(function() {
if ($(this).val() == '${}') {
$(this).attr("checked", "checked");
}
});
$("#orderBy option").each(function() {
if ($(this).val() == '${}') {
$(this).attr("selected", "selected");
}
});
});
//-->
</script>
The best way is to make logical judgments on the jsp page
<!-- The following code is recommended -->
<input type="radio" name="visible" value="1" <c:if test="${==1}">checked="checked"</c:if>/>Show<br>
<input type="radio" name="visible" value="0" <c:if test="${==0}">checked="checked"</c:if>/>Hide<br>
Notes:
Copy the codeThe code is as follows:
<html>
<body>
<form method="post" action="">
<!-- If the reset function is used in the form, the following code is not recommended -->
<input type="radio" name="visible" value="1" />Show<br>
<input type="radio" name="visible" value="0" />Hide<br>
<select name="orderBy" >
<option value="0">0</option>
<option value="1">1</option>
</select><br>
<input type="reset">
</form>
</body>
</html>
Not recommended: Use the following js code
Copy the codeThe code is as follows:
<script type="text/javascript">
<!--
$(function(){
//It is not the default value of the data when echoing
$("input[type=radio][name=visible]").each(function() {
if ($(this).val() == '${}') {
$(this).attr("checked", "checked");
}
});
$("#orderBy option").each(function() {
if ($(this).val() == '${}') {
$(this).attr("selected", "selected");
}
});
});
//-->
</script>
The best way is to make logical judgments on the jsp page
Copy the codeThe code is as follows:
<!-- The following code is recommended -->
<input type="radio" name="visible" value="1" <c:if test="${==1}">checked="checked"</c:if>/>Show<br>
<input type="radio" name="visible" value="0" <c:if test="${==0}">checked="checked"</c:if>/>Hide<br>