...

View Full Version : Url



joesruddock
04-15-2011, 05:27 PM
Hi Guys,

I want to have a text field where someone can enter a URL to go to. How can I do this?

Maybe a stupid questions lol!

Thanks

Joe

kansel
04-15-2011, 09:53 PM
Despite the fact that everyone already has a text field into which they can enter a URL and go anywhere in the WWW built into their browser...



<form action="#" onsubmit="window.location='http://'+this.url.value;return false;">
<input type="text" name="url">
<input type="submit" value="Go">
</form>

joesruddock
04-15-2011, 10:30 PM
I know it sounds odd lol XD Thanks for the info.... Basically what I am trying to do is have a place where a user can enter their membership number into a text field, hit submit and they will be forwarded to their profile.

Is there any way that the first part of the URL can be hidden so they just have to put the username in the box....

e.g :

Hidden bit : http://www.yourdomain.co.uk/user/

Then in the text field : 01010101


Hope this makes sense...

Thanks

kansel
04-16-2011, 03:36 AM
Just like you said.



<form action="#" onsubmit="window.location='http://www.yourdomain.co.uk/user/'+this.user.value;return false;">
<input type="text" name="user">
<input type="submit" value="Go">
</form>


Put 01010101 in the box and hit go will take you to http://www.yourdomain.co.uk/user/01010101 - of course this can't check whether that is a valid URL.

joesruddock
04-16-2011, 09:26 AM
Thanks for the help :D Much appreciated :D

joesruddock
05-06-2011, 02:59 PM
<form action="#" onsubmit="window.location='http://www.yourdomain.co.uk/user/'+this.user.value;return false;">
<input type="text" name="user">
<input type="submit" value="Go">
</form>

How would I add a file format after the user e.g.

http://www.yourdomain.co.uk/user/userinput.fileformat ?

Apostropartheid
05-06-2011, 05:27 PM
<form action="#" onsubmit="window.location='http://www.yourdomain.co.uk/user/'+this.user.value;return false;">
<input type="text" name="user">
<input type="submit" value="Go">
</form>

How would I add a file format after the user e.g.

http://www.yourdomain.co.uk/user/userinput.fileformat ?

Have you attempted to do this yourself?

kansel
05-07-2011, 04:19 AM
If the file format is a known static value (like .html) then after the this.user.value part put a plus sign and then the extension with single quotes around it.

<form action="#" onsubmit="window.location='http://www.yourdomain.co.uk/user/'+this.user.value+'.fileformat';return false;">
<input type="text" name="user">
<input type="submit" value="Go">
</form>
*You might need to scroll the code text box to see the changes highlighted in blue.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum