How to pass arrays and values into javascript function. fund and agent pass as an array. fromDate and toDate are pass as a single variable.
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>
I'm able to pass single variables into query string like that
?fund=PMF&agent=Balaji&fromDate=5-8-2013%209:33:6&toDate=10-8-2013%209:33:14
problem with array.
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
fund and agent are array types it is depend upon user it select single value or multiple value. fromDate and toDate are single values