Reputation: 1141
I have a application where values are passed to a asp page by QueryString as shown in the code below, this call is done from JavaScript function. Now I need to pass the same values to the asp page without the use of QueryString, is it possible to pass the values to start.asp page using anything other than QueryString?
location.href = "start.asp" +
"?var1=" + someval1+
"&var2=" + someval2;
Upvotes: 1
Views: 1776
Reputation: 189457
Include in your page a small form:-
<form id="frmStart" method="POST" action="start.asp" style="display:none">
<input name="var1" />
<input name="var2" />
</form>
Your code would then be:-
var frmStart = document.getElementById("frmStart");
frmStart.var1.value = "val1";
frmStart.var2.value = "val2";
frmStart.submit();
The "start.asp" would the access the posted values as:-
Dim var1 : var1 = Request.Form("var1")
Dim var2 : var2 = Request.Form("var2")
If the list of possible variables is itself dynamic then you could use some javascript to create the form dynamically.
function post (url, data)
{
var frmStart = document.createElement("form");
document.body.appendChild(frmStart);
frmStart.action = "start.asp";
frmStart.method = "POST";
foreach (var name in data)
{
var inp = document.createElement("input");
inp.name = name;
inp.value = data[name];
frmStart.appendChild(inp);
}
frmStart.submit();
}
post("start.asp", {var1: "val1", var2: "val2"} );
Upvotes: 2
Reputation: 39413
The only two methods for sending values are GET
(QueryString) or POST
.
You can make a post call easily in JavaScript or more easily with jQuery
$.post("start.asp", { var1: "val1", var2: "val2" } );
Upvotes: 2