/    Sign up×
Community /Pin to ProfileBookmark

pass location.search.substring(1) as a variable to another page

How do i pass

location.search.substring(1)

as a variable to another page? Something like the following.

<a href=”myPage.cfm?myVars=location.search.substring(1)”>Click Here</a>

Thanks in advance!!

to post a comment
JavaScript

5 Comments(s)

Copy linkTweet thisAlerts:
@fredmvFeb 11.2004 — Welcome to the forums.

If you have server-side available &#8212; which it appears you do (ColdFusion) &#8212; there should be a way to do this without JavaScript. You should not generate any content whatsoever using JavaScript; especially when there are more practical methods available.
Copy linkTweet thisAlerts:
@weaponXauthorFeb 11.2004 — Thanks for the welcome.

Allow me to explain my issue a bit more.

I have a coldfusion application that launches HTML pages. These HTML pages can't use any server side technology.

I want in js to grab some vars that are passed from the original cfml page to the html to be passed back to the coldfusion app upon close of a button.

The cfml page will then parse the string sent back which will look something like: myVars=123&steven

Hope that made some sense! or maybe there is a better way in js that I don't know about.

Thanks for your time!
Copy linkTweet thisAlerts:
@fredmvFeb 11.2004 — I see; here's how it'd be done:&lt;script type="text/javascript"&gt;
//&lt;![CDATA[
document.write('&lt;a href="foo.cfm?' + location.search.substring(1) + '"&gt;bar&lt;/a&gt;');
//]]&gt;
&lt;/script&gt;
Copy linkTweet thisAlerts:
@weaponXauthorFeb 11.2004 — sweet!

I didn't realize that was the syntax for adding that to the url. That did the trick.

Really appreicate such a quick, accurate resposne!

Have a great day!
Copy linkTweet thisAlerts:
@fredmvFeb 11.2004 — You're very welcome &#8212; I hope you have a great day yourself. ?
×

Success!

Help @weaponX spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...