views:

47

answers:

1

Hey guys,

I've got the following function

function make(point, name, message, type, file, id, lat, lng)

I want this function to pass all of these Javascript variables to a php file which would open in a window when a link is pressed how would I do this?

+5  A: 
window.open('path/to/php?point=' + point + '&name=' + name); // etc for all other vars

make sure the values of your variables are urlsafe, i'd urlencode them with:

encodeURIComponent(variable);

Edit re your comment

<a href="#" onclick="make(vars, go, here); return false;">Click me!</a>

but if thats all you want, you might as well just have the link open in a blank window:

<a href="path/to/php?point=foo&etc=bar" target="_blank">Click me!</a>

It depends if make() is doing something else other than opening a window, i suspect so?

Andrew Bullock
Up vote, you got in before me. I'd do this too.
DavidYell
How would I make this code only execute when a link is pressed?
Ulkmun