View Full Version : A wierd script I need.

06-22-2004, 09:26 AM
Hi, I was wondering if theres a way that I can get a script where the viwer of my site can enter the last section of a URL into a form, hit go, and...go to it :)


somebody enters bobby into the text box, and hit's go: It will take them to www.mysite.com/bobby

somebody enters chipfry.html : takes them to www.mysite.com/chipfry.html

Help would be greatly appriciated

06-22-2004, 01:16 PM
<form action="javascript://" onsubmit="location.href = location.protocol + '//' + location.hostname + '/' + this.elements[0].value; return false;">
<input type="text" value="index.html"/><input type="submit"/>

Would be more accessible to use a PHP script or something server-side, but this suffices for client-side.

06-22-2004, 05:11 PM
I'll try that, but If I can get a php, that's great.

Edit: I tried it, it's alng the lines of what I need, but not quiet.

I need it to go to a different server.com/whateva not the CURRENT ONE.

at the moment it goes to www.free.hostultra.com/inputedword

I need it to go to www.myotherwebhost.com/inputedword

Php, SSI, anythin is fine.


Roy Sinclair
06-22-2004, 05:37 PM
Replace the "location.hostname" in the script with the appropriate hostname literal.

06-22-2004, 08:46 PM
Hmm, doesnt work...

Roy Sinclair
06-22-2004, 10:19 PM
Hmm, doesnt work...

Show the code you're using. We know what we intended but without seeing what you're actually running...

06-23-2004, 07:51 AM
Does your code look like this?

<form action="javascript://" onsubmit="location.href='http://www.myotherwebhost.com/' + this.elements[0].value; return false;">
<input type="text" value="index.html" />
<input type="submit" />

06-23-2004, 06:12 PM
Nah, It's ok now, I found something suiting my needs on a javascript site, thanks for help tho :D