Hi,
i have a page with pictures on it, when a user clicks on a picture 2 things happen at the same time a new window pops up and a function is called.

the function does a few checks then calls another page when it calls this page i want to use a querystring, but i want to send data from a database.

i understand js is client side so how do i use server data with it?

the only way i could think of doing this was to put the data needed into a variable then use the code below to call the function and pass on the variable

<a href="http://www.someurl.com" onclick="openwin(testvar)" target="_blank"><img src=[URL]http://www.pic.com/pic.jpg[/URL] width="125" height="125" alt="some picture" border="0"/></a>

then once the function has received the variable it can use it to open the page with the querystring

function openwin(testvar){ 
if(popUpsBlocked)window.location.replace("sorrypop.asp"); 
else
window.open("tmp.asp?var="+testvar);}

this doesnt work for me am i doing something wrong or am i way of track if anyone could point me in the right direction would be really helpful

i understand javascript can't see server data which is why i said before that i have put the data into a variable (which to my understanding can then be used client side) this variable can then be used with the function.

have i still got it wrong??

the code you have provided wont work unless 'testvar' is some global variable.

if you want to pass the string 'testvar' to the function openwin:

<a href="http://www.someurl.com" onclick="openwin('testvar')" target="_blank"><img src=http://www.pic.com/pic.jpg width="125" height="125" alt="some picture" border="0"/></a>

note the single quotes; double quotes obviously wont work here.

if that's not the problem; perhaps you need to be more specific about exactly what you're trying to do..

thanks for the replies,

ok, yes i want to use the variable with this function so this is how i have declared the variable, i am using ASP as for the server side

<%
var testvar = (Recordset1.Fields.Item("testvar").Value);
%>

while writing this i have just realised i cant use this variable as it is server side, is there a way i can use this or am i best posting this on ASP forum.

If i remember my ASP correctly, then this kind of thing should work; although it's somewhat ugly looking...

<a href="[URL]http://www.someurl.com[/URL]" onclick="openwin('<% Response.write(testvar);%>');" target="_blank"><img src=http://www.pic.com/pic.jpg width="125" height="125" alt="some picture" border="0"/></a>

If you're still having problems, the ASP forum might be the better place to ask.

thanks so much

that work straight away,i thought i had already tried it but obvoiusly not

This article has been dead for over six months. Start a new discussion instead.