我在html(SelectTest.html)中创建了一些select.get标签,我试图做的是从选择标签中选择任何值后,我需要页面刷新并将所选选项作为参数传递给url。无法设置jquery mobile中选择标签的值
然后,我需要将页面刷新后设置为选定值。我不确定这个问题是否与jQuery mobile有关。
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.0a3/jquery.mobile-1.0a3.min.css" />
<script type="text/javascript" src="http://code.jquery.com/jquery-1.5.min.js"></script>
<script type="text/javascript" src="http://code.jquery.com/mobile/1.0a3/jquery.mobile-1.0a3.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
var param = window.location.search;
if(param)
{
var indx = param.indexOf("=");
//now get the value of selected type
aval =param.substring(indx+1);
$("#lang").val(aval);
}
$("#lang").change(function(){
var sel = $(this).val();
window.location.href="SelectTest.html?type="+sel;
});
});
</script>
<title>Insert title here</title>
</head>
<body>
<div data-role="page" id="home" data-theme="e">
<div data-role="header">
<h1>Test</h1>
</div>
<div data-role="content" id="toi">
<div>
<label for="lang">Select Language</label>
<select name="language" id="lang">
<option value="en">English</option>
<option value="hi">Hindi</option>
<option value="sp">Spanish</option>
<option value="fr">French</option>
</select>
</div>
<div id="main">
</div>
</div>
</div>
<div data-role="footer">
<h4>Test</h4>
</div>
</div>
</body>
</html>
对我的作品在Chrome,所以是的,它可能是在移动 – Mrchief
一个问题是吗?即使我尝试铬,但没有运气。该选项即使在页面刷新后也被更改。对我而言,每次只有英文选项被选中 – JavaGeek
它适用于每个选项。也许你在页面上还有其他的东西? – Mrchief