First of all, let’s take a look at what the echo means?
When an error occurs in data submission, the filled-in information is still in the text box. For example, when a user logs in, when the user enters an incorrect password, the username is still in the text box, but the password box is cleared. .
For some forms that require a lot of information to be filled in, it is very unfriendly to users if the entire form information that has already been filled in is refilled due to some errors.
jQuery echo also means this, so how to implement it?
Here we use the select drop-down box for demonstration. I hope it will be helpful to everyone.
html code:
<label>会议类型</label> <select id="select1" name="meets.meetType" style="display:inline;position:relative;top:10px;margin-bottom:20px;background:grey;"> <option value="现场会议">现场会议</option> <option value="视频会议">视频会议</option> <option value="语音会议">语音会议</option> </select> <input type="hidden" id="meettype" value="<s:property value="meets.meetType" />"/>
Note: The input tag here is used for identification in JQuery.
(meets has corresponding get and set methods in the upper layer action, which is necessary, otherwise the corresponding value cannot be obtained in this code)
The following is the code in JQuery, used to obtain control based on the corresponding id in html:
script type="text/javascript"> $(document).ready(function() { var nameselect=$("#meettype").val(); var all_select=$("#select1 > option"); for(var i=0;i<all_select.length;i++){ var svalue=all_select[i].text; if(nameselect==svalue){ //取select中所有的option的值与其进行对比,相等则令这个option添加上selected属性 $("#select1 option[value='"+svalue+"']").attr("selected","selected"); } } }); </script>
That's it!
The above is the detailed content of What does jquery echo mean?. For more information, please follow other related articles on the PHP Chinese website!