PDA

View Full Version : Redirect with data pulled in from URL



Timmyshh
Mar 11th, 2007, 03:46 AM
Hi,

I am trying to set up a redirect that will grab some data from the url and put it into the referred url. For example:

The URL to be referred would be: http://www.acme.com/survey.html?C=1234

So far I have:

<script type="text/javascript">
<!--
window.location = "http://www.acme2.com/survey.html (how do I add the C=1234 data here if the C value is to be dynamic)"
//-->
</script>

The C variable will change and so will need to be updated into the referred URL.

I'm quite new to Java, and would VERY much welcome any help!

Thanks in advance,
Tim :thumbsup:

brandonH
Mar 11th, 2007, 07:38 AM
just to let you know, JAVA and javascript are two totally different things.

to answer your question though, if you want the value of the C value to be variable and it to be reflected in the address bar when the page goes somewhere, do something like so:




<script type=text/javascript>
function ChangeC(value){
window.location="http://www.acme2.com/survey.html?C="+value
}
</script>


you would pass the value to the function like so:

<input type=button value="changeC" onclick="ChangeC('1234');">
<input type=button value="changeC" onclick="ChangeC('2345');">
<input type=button value="changeC" onclick="ChangeC('3456');">


the above is a crude example, im sure its not exactly what you are looking for as far as a way to do the change, its just an example to show you how it works.

Timmyshh
Mar 11th, 2007, 10:35 AM
Thanks for the info Brandon, will give it a shot.

Tim