JavaScript - How can I pass a variable value into <A HREF>

Asked By Michele Hobson on 06-Jun-05 09:38 AM
How can I pass multiple variable values into a JavaScript <A HREF> tag?

javascript

Asked By Heavens Martini on 06-Jun-05 09:56 AM
what do you mean?
you want to have some variables in the querystring?
or you want to change a style attribute of the tag?
perhaps an example would be helpful

You have to be more specific

Asked By Peter Bromberg on 06-Jun-05 10:20 AM
Do you want to put the names and values of javascript variables on to a URL querystring?

Variables in <A HREF> tag

Asked By Michele Hobson on 06-Jun-05 10:27 AM
I am trying to download a file from the portal to any users PC.  
var userName // does equal michelehobson
var jobName  // does equal any print file
My code states:
result += "<TD><A HREF='cgi-lawson/webrpt.exe?_DTGT=&_FN=/apps/law/DEV/law/print/userName/jobName/1/...
Both of the variables contain the correct values, however, inside of the <A HREF> tag it doesn't view userName or jobName as variables.  It actually tries to use the variable names in the path instead of their values.
Variables in <A HREF> tag
Asked By Michele Hobson on 06-Jun-05 10:33 AM
I am trying to download a file from the portal to any users PC.   
var userName // does equal michelehobson 
var jobName  // does equal any print file 
My code states: 
result += "<TD><A HREF='cgi-lawson/webrpt.exe?_DTGT=&_FN=/apps/law/DEV/law/print/userName/jobName/1/... 
Both of the variables contain the correct values, however, inside of the <A HREF> tag it doesn't view userName or jobName as variables.   It actually tries to use the variable names in the path instead of their values.
not sure
Asked By Heavens Martini on 06-Jun-05 10:38 AM
perhaps you need to "click" the link you have created and paste the entire url in a message, so I can see it.
the part you are showing appears to be syntactically correct.  
its www.eggheadcafe.com?varname=varvalue&varname2;=&varvalue2;
Variables in <A HREF> tags
Asked By Michele Hobson on 06-Jun-05 10:51 AM
result += "	<TD><A HREF='/cgi-lawson/webrpt.exe?DTGT=&_FN=
/apps/law/DEV/law/print/userName/jobName/1/HR211.prt&_DMD=PRTRPTA'>
Download </A></TD>\n"
ok
Asked By Heavens Martini on 06-Jun-05 11:37 AM
if you click on it, what happens?  
a file doesnt open? 
It appears to be correct, are you having trouble getting the two variables from querystring?
Shouldn't it be more like
Asked By Peter Bromberg on 06-Jun-05 11:47 AM
result += " <TD><A HREF='/cgi-lawson/webrpt.exe?DTGT=&_FN= 
/apps/law/DEV/law/print/' + userName +'/' +jobName+ '/1/HR211.prt&_DMD=PRTRPTA'> 
Download </A></TD>\n"
Variables in <A HREF> tag
Asked By Michele Hobson on 06-Jun-05 11:53 AM
If I use hard code the user and job name in the tag, it brings up a file dialog box and actually saves the file.  If I just change the actual username to the variable userName, I get an error
okay
Asked By Heavens Martini on 06-Jun-05 12:01 PM
I think Pete is on the "more righter" track... 
here is what I would do, if these links are coming from a script language out of a db.
I will say asp/vbscript.
response.write "<a href=""javascript:runreport('"& theusernameval &"','"& thejob&"');"">Download</a>"
then have a javscript function that takes those two arguments.
<script type="text/javascript">
 function runreport(usern,thejob)
{
var theurl = 'thebaseurl';
theurl += '?_theusernamevar='+ usern;
thejob += '&_thejobnamevar=' + thejob;
window.location = theurl;
}
</script>
Variables in <A HREF> tag
Asked By Michele Hobson on 06-Jun-05 01:09 PM
The example Peter supplied, provided a partial resolution.  In the code:
result += "	<TD><A
HREF='/cgi-lawson/webrpt.exe?DTGT=&_FN=/apps/law/DEV/law/print/" + userName + "/jobName/1/HR211.prt&_DMD=PRTRPTA'>Download </A></TD>\n" 
provided me with the actual username.  I applied (" +) for the jobname as well, but it did not work.  It also, would not accept single quotes.  Thank you for your help, I will keep plugging away at it.
redirect to login page after session time out
Asked By jayachandra reddy on 07-Jun-05 12:38 AM
how to redirect the user to login page after session time out is expired