Old 11-07-2006, 00:20   #1 (permalink)
evilsmiley
Registered User
 
Join Date: Jul 2006
Posts: 5
text box to url

Ok this may be a basic thing i am not familiar with, but i cant figure it out. I am looking for a way to have a text box where users can input data that will be added to the end of a url. So if they input say chris, then it would go to www.mydomain.com/chris. I dont want them to have to enter the whole url, just the last part. If anybody has any ideas, or knows how to do this I would greatly aprechiate it. Thanx in advance,
Colin
  Reply With Quote
Old 11-07-2006, 07:00   #2 (permalink)
MikeMackay
Everything is fine.
 
MikeMackay's Avatar
 
Join Date: Feb 2005
Location: Witham & London
Posts: 828
Send a message via MSN to MikeMackay Send a message via Skype™ to MikeMackay
This is easily accomplished. You have two options of going about; Client Side or Server Side.

You would need a simple HTML form that contains a text box for the user to enter their data for which will get appended to your specified URL and of course, you would need a submit button.

If you want a client side solution then you'll be looking at JavaScript. Basically using JavaScript you can redirect the user/browser to the pre-defined URL of your choice, including their appended data, straight from the page. However, if the visitor has JavaScript disabled the function will fail to work.

If you want a server side solution then you can use pretty much any language, but I would recommend using PHP. When the user submits the form, the data would then get sent to the PHP code (on the server) and it would append the data to your pre-defined URL and then the re-direct would take place.

Both methods, as you can see, will have the same effect/outcome. The PHP will work even if JavaScript is disabled and can prevent the user for altering the URL you define, therefore it is safer. If this is a mission critical function, then I'd suggest going with PHP for its robustness and added layer of security. With PHP you could also log which URLs are visited etc etc.

Hope that helps a little.

- Mike
  Reply With Quote
Old 11-07-2006, 14:29   #3 (permalink)
evilsmiley
Registered User
 
Join Date: Jul 2006
Posts: 5
Thanx, ya i knew u could do it in java. The problem is i dont know php and although i kno u can do it in java and it is a simple script i dont really know java all that well. I have written aplications in java before, but never anything web based. If somebody could write this code in either language for me i would greatly aprechiate it. If anybody does this for me just let me know if there is anything i can ever do for u .
  Reply With Quote
Old 12-07-2006, 06:11   #4 (permalink)
MikeMackay
Everything is fine.
 
MikeMackay's Avatar
 
Join Date: Feb 2005
Location: Witham & London
Posts: 828
Send a message via MSN to MikeMackay Send a message via Skype™ to MikeMackay
First things first; JavaScript is NOT Java. They are two completely seperate languages. If you have written something in Java then writing something in JavaScript is different.

To be honest, I don't think people on here will do the work for you just because you've asked. Someone probably will if you offer to send a £ or two their way as most people here are web developers/designers by profession and are unable to spend their time doing "freebies". You might get lucky though if someone is willing to do it in their spare time, but don't rely on it happening.

The sort of JavaScript is commonly found on many JavaScript sites , such as javascript.internet.com. If all else fails, try a search in Google.

- Mike
  Reply With Quote
Old 12-07-2006, 12:37   #5 (permalink)
evilsmiley
Registered User
 
Join Date: Jul 2006
Posts: 5
Thanx, ya i didnt really think i was gonna get anything for free, but i wasnt sure since its such a simple script. But thanx for your help.
  Reply With Quote
Old 13-07-2006, 06:47   #6 (permalink)
ludesign
ExCoder
 
ludesign's Avatar
 
Join Date: Mar 2006
Location: In The Darkness
Posts: 33
Send a message via ICQ to ludesign Send a message via MSN to ludesign Send a message via Yahoo to ludesign Send a message via Skype™ to ludesign
Quote:
Originally Posted by evilsmiley
Thanx, ya i didnt really think i was gonna get anything for free, but i wasnt sure since its such a simple script. But thanx for your help.

Well, sometimes if you had a luck and there's a nice and cute pplz around you, you can get something for free
And because i'm mainly a programmer and less a designer so i'll help you.

HTML Code:
<html> <head><title> Quick URL's by ludesign </title> <script type="text/javascript"> // define goTo function with one argument function goTo(location) { // define variable locationObj and stote window.location object in. var locationObj = window.location; // define variable hostname and store your domain and desired path in. var hostname = "http://" + locationObj.hostname + "/" + location; // redirect the user to new location locationObj.href = hostname; } </script> </head> <body> <input type="text" name="location" id="location" size="15"> <input type="button" value="Go!" onclick="goTo(document.getElementById('location').value);"> </body> </html>

This is simple and easy to use script. Save it as redirect.html and upload it to your server, then just type in the box (input field) something (let's say you have subdirectory on your host named test with file called index.html in, then just type test in the fields and press Go! button...

If you have any questions, feel free to ask

I hope this will help you.
  Reply With Quote
Old 14-07-2006, 22:08   #7 (permalink)
evilsmiley
Registered User
 
Join Date: Jul 2006
Posts: 5
Wow thank you soooo much. I had to slightly moddify it, but it was almost exactly what I wanted. Thanx again. I dont know anything about javascript so i couldnt write this myself. I dont know what else to say besides thanx a ton.
  Reply With Quote
Old 15-07-2006, 00:15   #8 (permalink)
ludesign
ExCoder
 
ludesign's Avatar
 
Join Date: Mar 2006
Location: In The Darkness
Posts: 33
Send a message via ICQ to ludesign Send a message via MSN to ludesign Send a message via Yahoo to ludesign Send a message via Skype™ to ludesign
Quote:
Originally Posted by evilsmiley
Wow thank you soooo much. I had to slightly moddify it, but it was almost exactly what I wanted. Thanx again. I dont know anything about javascript so i couldnt write this myself. I dont know what else to say besides thanx a ton.

You are welcome
  Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search


Contact Us - Web Design Forums - Archive - Top
Search Engine Optimization by vBSEO 3.0.0 RC8