| | |
help on passing variable to a function?
Please support our JavaScript / DHTML / AJAX advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Jun 2007
Posts: 5
Reputation:
Solved Threads: 0
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
then once the function has received the variable it can use it to open the page with the querystring
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 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
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
<a href="http://www.someurl.com" onclick="openwin(testvar)" target="_blank"><img src=<a rel="nofollow" class="t" href="http://www.pic.com/pic.jpg" target="_blank">http://www.pic.com/pic.jpg</a> 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
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
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
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:
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..
if you want to pass the string 'testvar' to the function openwin:
HTML Syntax (Toggle Plain Text)
<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..
Plato forgot the nullahedron..
•
•
Join Date: Jun 2007
Posts: 5
Reputation:
Solved Threads: 0
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
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.
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
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
<% 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...
If you're still having problems, the ASP forum might be the better place to ask.
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
<a href="<a rel="nofollow" class="t" href="http://www.someurl.com" target="_blank">http://www.someurl.com</a>" 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.
Plato forgot the nullahedron..
![]() |
Similar Threads
- Purpose of Pointers? (C++)
- Using Client(JS) to get Server(VBS) value. (ASP)
- Multithreading error (C++)
Other Threads in the JavaScript / DHTML / AJAX Forum
- Previous Thread: Really simple script request - Count from 6 - 0
- Next Thread: form field value change onclick
| Thread Tools | Search this Thread |
acid2 ajax ajaxcode ajaxhelp animate array automatically beta box bug calendar captcha cart checkbox class codes column cookies createrange() css cursor date debugger decimal design dom download dropdown editor element enter error events explorer firefox focus form frameworks getselection google gwt html htmlform iframe image() images index internet java javascript jawascriptruntimeerror jquery jsf jsfile jsp listbox maps masterpage matrixcaptcha menu microsoft mimic mp4 object onmouseover parent php player post problem programming progressbar prototype rating redirect regex runtime safari scale scriptlets search select session shopping size sql starrating stars text textarea toggle validation variables w3c website window windowofwords windowsxp wysiwyg xml






