如何将数组和值传递给 javascript 函数。基金和代理作为数组传递。fromDate 和 toDate 作为单个变量传递。
function fetch_javaScript(fund,agent,fromDate,toDate)
{
-------
-------
var agent = document.getElementById('agent').value;
var fromDate = document.getElementById('fromDate').value;
var toDate = document.getElementById('toDate').value;
var queryString = "?fund=" + fund_name ;
queryString += "&agent=" + agent ;
queryString += "&fromDate=" + fromDate;
queryString += "&toDate=" + toDate;
ajaxRequest.open("GET", "final_ajax.pl" +
queryString, true);
}
<tr><td>
<h2>Funds</h2>
</td>
<td><select name="Funds" id="fund" multiple >
<option value="Select">Select</option>
<option value="PMF">Principal</option>
<option value="PRAMERICA">Pramerica</option>
<option value="JM">JM</option>
<option value="DHL">DHL</option>
<option value="EMF">Edelweiss MF</option>
----
----
</select> <br></td>
</tr>
<tr><td>
<h2>Agents</h2>
</td>
<td><select name="Agents" id="agent" multiple>
<option value="Select">Select</option>
<option value="Gyanesh">Gyanesh</option>
<option value="Satish">Satish</option>
<option value="Sailesh">Sailesh</option>
<option value="ArchanaMuluguru">Archana</option>
----
----
</select></td>
</tr>
我能够像这样将单个变量传递给查询字符串
?fund=PMF&agent=Balaji&fromDate=5-8-2013%209:33:6&toDate=10-8-2013%209:33:14
数组的问题。
How can I build a querystring looks like that?
?fund[]=["PMF","JM"]&agent[]=["Balaji"]&fromDate=5-8-2013%209:33:6&toDate=10-8-2013%209:33:14
基金和代理是数组类型,它取决于用户选择单值或多值。fromDate 和 toDate 是单个值