Click here to Skip to main content
15,867,453 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi All,

Cracking my head from long time with this problem, th problem is how to pass multiple query strings in a window.open() in javascript

JavaScript
var result = window.open('<%=Url.Action("VehicleSearchOnMap?scheduleId=") %> ' + dropdown, "", "dialogWidth:875px;dialogHeight:600px");


Here i am able to pass single parameter, but when i try to add multiple parameter it gives me too many chacters in a literal exception, can any one please help me out in solving this issue


Thank you
Posted
Comments
[no name] 27-Mar-12 11:09am    
What is dropdown?
manu g m 27-Mar-12 11:12am    
dropdown is an variable which gets the value from dropdown,
var dropdown = document.getElementById("vehicleschedule").value;

My problem is how to pass the second variable in the query string. of window.open()
[no name] 27-Mar-12 11:19am    
Do you know how to form a query string? Are you using ? and value names with & to separate name/values?
manu g m 27-Mar-12 11:22am    
I donno much about javascript. It will be helpful if you give me an example of how to build query string

C#
function Test() {
    var value1 = 100;
    var value2 = 200;
    var value3 = 300;
    window.open('<%=Url.Action("Index?param1=") %> ' + value1 + '&param2=' + value2 + '&param3=' + value3, "", "dialogWidth:875px;dialogHeight:600px");
}
 
Share this answer
 
Comments
manu g m 30-Mar-12 8:10am    
Thanks a lot, the above solution worked :) :)
You can do this way. For example I am opening http:www.google.com with two parameters in the query string.

C#
function test()
 {
 var value1 =100;
 var value2 =200;
 window.open("http://www.google.com?param1=" + value1 + "&param2=" + value2, "", "dialogWidth:875px;dialogHeight:600px");

 }


Ok try this way ...

C#
function Test() {
    var value1 = 100;
    var value2 = 200;
    var value3 = 300;
    window.open('<%=Url.Action("Index?param1=") %> ' + value1 + '&param2=' + value2 + '&param3=' + value3, "", "dialogWidth:875px;dialogHeight:600px");
}
 
Share this answer
 
v2
Comments
manu g m 27-Mar-12 12:32pm    
will this work with the single quotes, if you observe i have single quotes within window.open('<%=url.action("")%>), and inside that i have double qoutes
Anish_Ravindran 27-Mar-12 12:59pm    
Please try the updated solution.
Just to clear some confusion - there is no real reason why you should add quotes (single or double) to the values of parameters in querystring.

These quotes are important only for the application reading the querystring. Any sanely designed application should/would not apply any significance to presence of quotes in the values of the querystring.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900