Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

passing and retrieving variable

Status
Not open for further replies.

Bamarama

Programmer
Dec 29, 2006
49
US
Hey gang. THis may be asked somewhere before, but I couldn't find it.

I am trying to pass a variable that is defined in a sql statement, to a
window.open page. I am not having any luck in being able to do this. Here is
what I have.
Oh, using asp, not php.

varida is the variable I am trying to pass. Normally, with a regular
querystring, it passes as ?id=<%=varida%>
but that doesn't give me the results.
so i have tried
Code:
function newwindow()
{
window.open('[URL unfurl="true"]http://mysite/edit_email.asp?id="[/URL] + varida + 
"','jav','width=300,height=300,resizable=yes,titlebar=no,toolbar=no');
}
and
Code:
function newwindow()
{
window.open('[URL unfurl="true"]http://mysite/edit_email.asp?id="[/URL] + <%=varida%> + 
"','jav','width=300,height=300,resizable=yes,titlebar=no,toolbar=no');
}
and
Code:
function newwindow()
{
window.open('[URL unfurl="true"]http://mysite/edit_email.asp?id="<%=varida%>"','jav','width=300,height=300,resizable=yes,titlebar=no,toolbar=no');[/URL]
}
none of the above will pass the variable.

can someone help me out here please??


much thanks

i also have this in the link part
<a HREF="javascript:newwindow('<%=varida%>')">


now when I hover the mouse, it does show the id in the status bar. so that
part is working.

is there a different way of retrieving a querystring other than

userid = request.querystring("id")

maybe that's the problem
 
What actual javascript do you get after server side transformation of the JSP?

Cheers,
Dian
 
It actually pulls the first ID from the database table, instead of the one I am clicking on.

i think that is what you are aking
 
Your quote ordering looks off. Try this:

Code:
function newwindow() {
	window.open('[URL unfurl="true"]http://mysite/edit_email.asp?id=<%=varida%>',[/URL] 'jav', 'width=300,height=300,resizable=yes');
}

If your server-side variable "varida" has spaces or other non-URL characters (or single quotes, for that reason), you would need to escape it server-side first.

Hope this helps,
Dan

Coedit Limited - Delivering standards compliant, accessible web solutions

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
Since you are passing varida into the function newwindow, why use that parameter?

This is what you have:
Code:
<a HREF="javascript:newwindow('<%=varida%>')">

Make newwindow this:
Code:
function newwindow([!]passedVarida[/!])
{
window.open('[URL unfurl="true"]http://mysite/edit_email.asp?id='[/URL] + passedVarida + ','jav','width=300,height=300,resizable=yes,titlebar=no,toolbar=no');
}

Do that, or use BRPS's code.


[monkey][snake] <.
 
ok, i got it... here is what i did.

on the actual link, i put
Code:
<a href="javascript:openWindow('edit_email.asp?id=<%=varida%>')">

then i have this as the script

Code:
<script language="JavaScript"> 
<!-- 
function openWindow(url, name)
 { 
popupWin = window.open(url, name, 'scrollbars,resizable,width=300,height=300,left=400,top=200'); 
}// --> 
</script>

and it is working now..

thanks for the replies and ideas :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top