PDA

View Full Version : dynamically changing parts of url's in an html code.



HELLSS
Jun 18th, 2002, 11:07 PM
I'm wondering if someone knows a way to have a visitor to a page input 2 fields, ID and password... and apply those fields to url's in already made pages.

So for example in a page would be the link
http://page.com/stuff/something.cgi?ID=SUPPLIEDID&PASS=SUPPLIEDPASS&CONTENT=blahblah

And the bolded parts of the url would be changed to the supplied id and password.

Is this possible with javascript even?

I don't have access to the site the links are to, making my own "interface" for an online game and am thinking of ways to easily allow others to use it as well. Thanks for the help :)

x_goose_x
Jun 18th, 2002, 11:13 PM
<html>

<head>
<script>
obj = new Array();
x = 0;
tmp = location.search;
function loop() {
tmp = tmp.substring(tmp.indexOf("=")+1,tmp.length);
if (tmp.indexOf("=") > 0) {
obj[x] = unescape(tmp.substring(0,tmp.indexOf("&")));
x += 1;
setTimeout("loop()",10);
}else{
obj[x] = unescape(tmp.substring(0,tmp.length));
whattodo();
}
}
function whattodo(){
// change formname to the actual form name and the field names to the corresponding fields.
document.formname.user.value = obj[0];
document.formname.pass.value = obj[1];
document.formname.content.value = obj[3];
}
</script>
</head>

<body onload="loop();">

</body>

</html>