How to save the value selected in the drop-down box_html/css_WEB-ITnose

WBOY
Release: 2016-06-24 11:59:57
Original
1383 people have browsed it

//Invite
$("#userSelect").click(function () {
var v = $("#userSelect option:selected").text();

var text=$("#textYaoqing").val("Invited:" v);

  });


$('#yaoqingBtn').click( function () {

var uIds = $('#userSelect').val();
var tId = $('#TIdHidden').val();


           if (uIds                                                                                                                                           ed("Please select the inviter! ");

}
else {

var param = String.Format("action=yaoqing&common={0}&tId={1}", uIds , tId);

var htmlObj = GetAjax("HandlerPage", param);
var tid = $('#TIdHidden').val();

//if (htmlObj != "OK" )
                                                                                                        alert(htmlObj);                    🎜> SkipPage("TopicSingle", "tId =" tId);
How to save the value selected in the drop-down box, but the data is gone as soon as the data is refreshed. This is var v = $("#userSelect option:selected").text();
The value selected in the drop-down box The value is saved to $("#textYaoqing").val("Invited:" v); here




Reply to the discussion (solution)

Display after refreshing, requires cookies, or save to the server.

I tried, but it didn’t work. I’m not very familiar with cookies. Can you be more specific?


I tried, but it didn’t work. , I am not very familiar with cookies, can you be more specific?

When refreshing and reloading, first get the value from the cookie, and assign it to the drop-down box if it is obtained. If it cannot be obtained, it will be displayed by default

<!doctype html><html lang="en-US"><head>    <meta charset="UTF-8">    <title></title></head><body><input type="text" name="" id="txt"/><input id="btn" type="button" value="test"/><script type="text/javascript">    document.getElementById('btn').onclick = function(){        var d = new Date();        d.setDate(d.getDate() + 10);        document.cookie = 'value=' + document.getElementById('txt').value + ';expires=' + d;        console.log(document.cookie);    }</script></body></html>
Copy after login

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template