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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help with variable & link

Status
Not open for further replies.

C4rtm4N

MIS
Sep 29, 2004
54
GB
Hi

I'm a total Javascript novice & am having a lot of issues trying top get a variable that I have have populated passed as part of a link.

The header of the page contains the following script which works fine ....
<script language="javascript">
var sid = prompt("Please enter the tracking id that you have been issued with. Without this no payments will be made", "");
</script>

But then when I try to use the 'sid' variable in the link below, it doesn't see to get passed. Clearly my syntax is wrong but all I've done is replace a working static value of QQQ with "+sid+" (including the quotes).
<script type="text/javascript" language="javascript" src="
What am I doing wrong ?

Thanks

Steve
 
If you're including the script line on the same page as thr prompt, then the variable will not have been populated before the script is included.

You'd need to either dynamically write out the script like after getting the sid, or post a form with the sid to that url (using the "get" method if you need it in the URL).

Hope this helps,
Dan



Coedit Limited - Delivering standards compliant, accessible web solutions

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
Thanks Dan

Would it work if I was to replace sid with document.write(sid)? The example page that I looked at ( talks about the sid being poluated as the header of the page is loading so therefore it's available for when the body loads.

Steve
 
Sorry Dan - I got sidetracked with another project & hadn't been back to check responses - I tried it last night & yes it worked.

Many Thanks

Steve
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top