/    Sign up×
Community /Pin to ProfileBookmark

JS Redirect on Input

I am trying to make it so that whenever someone types a word or series of numbers into a textbox, that word shows up as an appendage to a URL. For example if someone types “joey123” then when they clicked on Submit it redirects them to [url]http://www.website.com/joey123.[/url] I have looked all over and I can’t seem to find anything. Just a little rusty I guess.

THANKS!

Ammon

to post a comment
JavaScript

6 Comments(s)

Copy linkTweet thisAlerts:
@2004028Nov 19.2004 — <script>

function insertName()

{

insert = document.myForm.name.value;

submitOK = "True";

document.write("http://www.website.com/" + insert);

return false;

}

</script>

<form name="myForm" onsubmit="return insertName()">

<input type="text" name="name" size="10">

</form>


Try this see if it is works.^^
Copy linkTweet thisAlerts:
@ammonlovellauthorNov 24.2004 — Okay well at least that was closer than I got, but it still didn't work. This code just reloads the same page but puts a document.write of the address. I need it to be a link that when they click on submit, it automatically loads the URL. Thanks though. Anymore ideas? The link, if you want to see is http://www.empowernet.com/newsite/order.html

Thanks!

Ammon
Copy linkTweet thisAlerts:
@TheBearMayNov 24.2004 — Change the document.write to:

document.location.href = document.location.href +"/"+ insert;
Copy linkTweet thisAlerts:
@ammonlovellauthorNov 24.2004 — Alright! One step closer, but it still isn't quite right. If you visit the page again (http://www.empowernet.com/newsite/order.html) you'll see it just appends the submission on the current webpage. I need it to append on a completely different URL. I assume the problem is with

document.location.href = document.location.href +"/"+ insert;

but I can't get it to change locatons. How would I do this?

THANKS!!!

Ammon
Copy linkTweet thisAlerts:
@TheBearMayNov 24.2004 — Change this

document.location.href = document.location.href +"/"+ insert;

to

document.location.href = "http://newURL/"+ insert;
Copy linkTweet thisAlerts:
@ammonlovellauthorNov 24.2004 — SWEET! It works! I had actually tried that but I forgot the quotes. Thanks a bunch!

Ammon
×

Success!

Help @ammonlovell spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.20,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...