View Full Version : Passing a var from javascript into a url on a web page
rainmanjam
Aug 23rd 2008, 11:05 pm
I have a variable that is in my javascript code. I would like to
create a url with variables from javascript to pass to another page.
Example:
http://www.bla.com/test.aspx?var1="jsvar1"&var2="jsvar2" etc.
What would be the best way of doing this?
serialCoder
Aug 23rd 2008, 11:10 pm
hmm, i dont fully understand but if you use the js for redirection you can probably use
window.location ="yourintendedpage.htm?jsvar="+jsVarValue+"&jsvar2="+jsvar2Value and so on...
xlcho
Aug 24th 2008, 4:01 am
Yep, you can do it that way either for redirection or a http request.
rainmanjam
Aug 24th 2008, 8:10 am
I'm trying to compose the following url
<a href=http://www.bla.com/test.aspx?var1="jsvar1"&var2="jsvar2"onclick="hidePopupMenu();">Mark</a>
vipinc007
Aug 25th 2008, 9:02 am
window.location.href="page.html?var1="+var1;
xlcho
Aug 25th 2008, 11:18 pm
As said earlier, to concatenate strings in javascript you must use + (plus sign). Just like you do it with a . (dot) in PHP. So, your code will have to be:
<a href=http://www.bla.com/test.aspx?var1="+jsvar1+"&var2="+jsvar2+" onclick="hidePopupMenu();">Mark</a>
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.