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!

CF var to JavaScript and back ???

Status
Not open for further replies.

ApexSys

Programmer
Jan 10, 2001
15
US
How do I pass a CF variable to another page if that second page is called by a Javascript function?

I have a record ID that I want to pass after clicking on a text link.
That link calls a JS function that has no knowledge (clientside) of the record ID which will be a CF (serverside) variable when submitted.

eg:
My original link is:
<A HREF = &quot;javascript:void(0)&quot; onClick=&quot;ShowCalendar()&quot;>text</a>

And I want to pass:
completed=#RecordID#
along with it to the next page.

The function (not shown) does a window.open to call the next page.
So passing a &quot;null page&quot; along with a URL variable didn't work.
eg: A HREF=&quot;##?completed=#RecordID#&quot; onClick=.......

I also tried adding var1=#completed# to the JS funtion in hopes of passing that to the next page but of course that too did not evaluate becuase the JS is client side only.

Any ideas, or pointers to a CF / JavaScript resource would be appreciated.

Thanks,
Apex

-=-=-=-=-=-=-=-=-=-=-=-=-=-
Apex Systems Consulting
e-Solutions for Small Business
 
Add an argument to your function ...
ShowCalendar(RecordId)

Then put the following in your CF code...

<cfoutput>
<a href=&quot;javascript:ShowCalendar(#var#);&quot;>link</a>
</cfoutput>

note: use single quotes around #var# if var is a string.

in your javascript function, do this ...
window.location.href='blah.cfm?Recordid='+RecordId;

HTH,
Marc
 
oh ... completed..... :)
window.location.href='blah.cfm?completed='+RecordId;

Marc
 
Marc,
Thanks....I had to modify the function quite a bit, but I figured it out.

-=-=-=-=-=-=-=-=-=-=-=-=-=-
Apex Systems Consulting
e-Solutions for Small Business
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top