嗨,我是 javascript 编程的新手,我正在 jquery mobile 中制作一个下拉列表视图(选择器视图),以便数据位于该选择器视图中,我创建了一个 json 数组。问题是我需要代码,当我单击特定列表视图时,它应该运行一个 js 函数,该函数从 json 数组中获取数据并将其放入选择器(列表)视图中。我的html代码是:
<form method="get" name="datarange">
<div data-role="fieldcontain">
<select id="number" name="day you need" onclick="dayLoad();">
<option value="select-value" selected="selected" >--Select Day--</option>
<option value="01">/* here i want my data from array "day"/*</option>
<option value="02">/* here i want my data from array "day"/*</option>
</select>
</div>
<div data-role="fieldcontain">
<select id="time" name="time you need">
<option value="select-value" selected="selected">--Select Time--</option>
<option value="101">/* here i want my data from array "Time" /*</option>
<option value="102">/* here i want my data from array "Time"/*</option>
<option value="103">/* here i want my data from array "Time"/*</option>
<!-- etc. -->
<option value="116">/* here i want my data from array "Time"/*</option>
</select>
</div>
<div data-role="fieldcontain">
<select id="pid" name="pid you need">
<option value="select-value" selected="selected">--No PID allocation found--</option>
<option value="301">/* here i want my data from array "pid"/*</option>
<option value="302">/* here i want my data from array "pid"/*</option>
</select>
</div>
<div data-role="fieldcontain">
<select id="jus" name="justification you need">
<option value="select-value" selected="selected">--Select Justification--</option>
<option value="201">Project Work</option>
<option value="202">Client Call</option>
<option value="203">Team Meeting<option>
<option value="204">Others</option>
</select>
</div>
</form>
<div id="display" class="rss-box"></div>
在我的 js 文件中:
var day=[
{"dayTime" : "Today-Drop"},
{"dayTime" : "Tomorrow-Pick up"}];
var time=[
{"PM" : "3:00 PM"},
{"PM" : "4:00 PM"},
{"PM" : "7:30 PM"},
{"PM" : "9:00 PM"},
{"PM" : "10:15 PM"},
{"PM" : "11:00 PM"}];
var Pid=[
{"pidno" : "7813"},
{"pidno" : "8133"},];
function dayLoad(){//i need the code to put in this function which grabs the data from array and gonna put into the listview}