Passing Variable from page to link

C

CHouck

I have what seems to be a simple problem but I can't figure it out.

I have a page where I have a link with variables built in which I want
to pass through the URL so another page can pick the info up.

My link on the first page (schedule.html) goes to this link:
disclaimer.html?customer=238297&EventID=19080

And I have some Javascript in the page which places the link info into
the URL:

<script language="JavaScript"><!--
function nextpage(href,string) {
location.href = href + '?' + string;
}
</script>

Now on the (disclaimer.html) page I want to receive the info in the URL
and then have a link that says "I Agree" that contains that dynamic
info. So the link would look something like this:
paymentpage.aspx?CustomerId=238297EventID=1908

The problem is I have a no idea how to GET this info into the link.

Any help anyone could give me would be greatly appreciated.
Thanks,
CHouck
 
M

mxa

hi,

you need server side code , do you have access to server ? what
languages are available?
parameter passed to a html document via get or post are avalable on
server side only.

if you don't have access to the server , you may want to consider
including or building the next html
thanks
Michael
 
M

McKirahan

CHouck said:
I have what seems to be a simple problem but I can't figure it out.

I have a page where I have a link with variables built in which I want
to pass through the URL so another page can pick the info up.

My link on the first page (schedule.html) goes to this link:
disclaimer.html?customer=238297&EventID=19080

And I have some Javascript in the page which places the link info into
the URL:

<script language="JavaScript"><!--
function nextpage(href,string) {
location.href = href + '?' + string;
}
</script>

Now on the (disclaimer.html) page I want to receive the info in the URL
and then have a link that says "I Agree" that contains that dynamic
info. So the link would look something like this:
paymentpage.aspx?CustomerId=238297EventID=1908

The problem is I have a no idea how to GET this info into the link.

Any help anyone could give me would be greatly appreciated.
Thanks,
CHouck

Will this work for you? Watch for word.wrap.

<html>
<head>
<title>disclaimer.html</title>
<script type="text/javascript">
var qstr = location.search;
qstr = qstr.replace(/\?/g,"&");
var pair = qstr.split("&");
var valu = new Array("","");
for (var i=1; i<pair.length; i++) {
var parm = pair.split("=");
if (parm[0] = "customer") valu[0] = parm[1];
if (parm[0] = "EventID") valu[1] = parm[1];
}
var page = "paymentpage.aspx"
page += "?CustomerId=" + valu[0];
page += "&EventID=" + valu[1];
function nextpage() {
location.href = page;
}
</script>
</head>
<body>
<a href="javascript:nextpage()">I agree</a>
</body>
</html>


Also, if your calling link looks like

<a
href="javascript:nextpage('http://www/','disclaimer.html?customer=238297&Eve
ntID=19080')">link</a>

why not remove the function by changing it to

<a href="http://www/disclaimer.html?customer=238297&EventID=19080">link</a>
 
M

McKirahan

hi,

you need server side code , do you have access to server ? what
languages are available?
parameter passed to a html document via get or post are avalable on
server side only.

Not true. You can access the querystring via location.search on the
client-side.
 
B

Börni

CHouck said:
I have what seems to be a simple problem but I can't figure it out.

I have a page where I have a link with variables built in which I want
to pass through the URL so another page can pick the info up.

My link on the first page (schedule.html) goes to this link:
disclaimer.html?customer=238297&EventID=19080

And I have some Javascript in the page which places the link info into
the URL:

<script language="JavaScript"><!--
function nextpage(href,string) {
location.href = href + '?' + string;
}
</script>

Now on the (disclaimer.html) page I want to receive the info in the URL
and then have a link that says "I Agree" that contains that dynamic
info. So the link would look something like this:
paymentpage.aspx?CustomerId=238297EventID=1908

The problem is I have a no idea how to GET this info into the link.

Any help anyone could give me would be greatly appreciated.
Thanks,
CHouck

Hi,
i hope i did unterstand right what you want, basically extracting GET
information from the url.
the following code snippet extracts everything after the first '=' in
the url. with a bit of string manipulation you can modify it for your needs.
And with a little DOM you can then modify the href attribute of the link
after the page is loaded.

if (window.location.search != "") {
var text = window.location.search;
var exempt =
text.substring(location.search.indexOf("=")+1,location.search.length);
}
 
C

CHouck

Thanks everyone for your help. I used McKirahan's (Thanks McKirahan)
code and everything seems to be working Ok the only thing I 'm having
problems with now is that when I click on the link that uses
nextpage(), the URL is passing the EventID to both string parameters.
So both CustomerID and EventID have the EventId in them. Any ideas...
Thanks again,
CHouck
 
M

McKirahan

CHouck said:
Thanks everyone for your help. I used McKirahan's (Thanks McKirahan)
code and everything seems to be working Ok the only thing I 'm having
problems with now is that when I click on the link that uses
nextpage(), the URL is passing the EventID to both string parameters.
So both CustomerID and EventID have the EventId in them. Any ideas...
Thanks again,
CHouck

Show us your code, please.
 
M

McKirahan

CHouck said:
I have what seems to be a simple problem but I can't figure it out.

I have a page where I have a link with variables built in which I want
to pass through the URL so another page can pick the info up.

My link on the first page (schedule.html) goes to this link:
disclaimer.html?customer=238297&EventID=19080

And I have some Javascript in the page which places the link info into
the URL:

<script language="JavaScript"><!--
function nextpage(href,string) {
location.href = href + '?' + string;
}
</script>

Now on the (disclaimer.html) page I want to receive the info in the URL
and then have a link that says "I Agree" that contains that dynamic
info. So the link would look something like this:
paymentpage.aspx?CustomerId=238297EventID=1908

The problem is I have a no idea how to GET this info into the link.

Any help anyone could give me would be greatly appreciated.
Thanks,
CHouck

Do the QueryString "names" ("customer" versus "CustomerId") have to be
different between the two pages?

disclaimer.html?customer=238297&EventID=19080

paymentpage.aspx?CustomerId=238297EventID=1908


If they could be made the same then you could just pass on the entire
QueryString:

<html>
<head>
<title>disclaimer.html</title>
<script type="text/javascript">
function nextpage() {
location.href = "paymentpage.aspx" + location.search;
}
</script>
</head>
<body>
<a href="javascript:nextpage()">I agree</a>
</body>
</html>

<a href="disclaimer.html?CustomerId=238297&EventID=19080">Disclaimer</a>
 
C

CHouck

You just answered my question...everything works great now.

Thank you !!!

CHouck

BTW, the customer versus customerID thing was my screwup it was just
supposed to be customerID for each page. My brains not running on all
cylinders these days.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,566
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top