html form help

SLEEPER5555

Golden Member
Aug 16, 2000
1,597
0
0
Ok i know this is html form ? not programming but it was the closest forum to what i want to do so maybe someone here can help.

I need to create a simple form code where there is one text field and a submit button, basically what i want it to do is when somone types "sampletext" in the form it takes them to www.mydomain.com/sampletext the closest i have gotten is this but i obviously still have something wrong

Anyone?
 

troytime

Golden Member
Jan 3, 2006
1,996
1
0
There are several ways to get this accomplished.
You could use some javascript in the form to change the action when the form is submitted, but i think it will still have the ?id=whateverinput tacked on (mydomain.com/whateverinput/?id=whateverinput)
You could use some javascript and a fake form button (a link) and the link dynamically use whatever has been input into that text input. This could be done onclick of the link, or as/after it is being typed into the text input.
You could use a server side scripting language like .net/ruby/php/perl/cgi to catch the input and redirect to the mydomain.com/inputtext/.
You could use mod rewrite to redirect the form action page (mydomain.com/form.html?id=inputtexthere) to the path format (mydomain.com/inputtexthere/)

Any preference?
 

SLEEPER5555

Golden Member
Aug 16, 2000
1,597
0
0
this option
You could use some javascript and a fake form button (a link) and the link dynamically use whatever has been input into that text input. This could be done onclick of the link, or as/after it is being typed into the text input.
sounds closest to wht i want to do, basically i just want it to be simple as possible thats why i was thinking just html but maybe your right it has to be at least java?
 

troytime

Golden Member
Jan 3, 2006
1,996
1
0
<form>
<input type="text" name="txtinput" id="txtinput"><br>
<input type=button name="Submit" Value="Submit" onclick="Javscript:gothere()">
</form>
<script>
function gothere() {
window.location = '/'+document.getElementById('txtinput').value+'/';
}
</script>
 

SLEEPER5555

Golden Member
Aug 16, 2000
1,597
0
0
troy, that sorta works the only problem is when you enter "test" for example in the form and the form is a few folders out for example mydomain.com/folder1/folder2/ this script takes you back to the root domain mydomain.com/test instead of mydomain.com/folder1/folder2/test anyway to change that? by the way thank you so much this is soo cool i was trying to figure this out but i kept running in circles
 

jmaker

Junior Member
Jun 21, 2004
17
0
0
Would this work?

window.location = location.pathname+document.getElementById('txtinput').value+'/';
 

SLEEPER5555

Golden Member
Aug 16, 2000
1,597
0
0
Ok something isnt right when type in the form and press enter it fails but when you click submit it works, how do we make enter = submit?
 

SJP0tato

Senior member
Aug 19, 2004
267
0
76
Right now you have your button's "onclick" attribute calling the javascript. It's not associated with the form though.

To get the behavior you want, change the button type to type="submit". If your button is within a form and is type submit, it will submit the form.

Next in the form, add the attribute onsubmit="yourJavascript". Cut out the text from your button onclick method and put it here instead.

Now hitting return within the form should work, along with clicking the button.


One last thing, typically the <script> blah blah </script> section goes in-between the <head> </head> tags.

Forgot to mention to take the "onclick" out of the button completely.
 

SLEEPER5555

Golden Member
Aug 16, 2000
1,597
0
0
ok i edited the code to the attached which is what i think you were saying to do and that doesnt work with either the click or enter. any other ideas?
 

troytime

Golden Member
Jan 3, 2006
1,996
1
0
i was going to call out your "javscript" typo, but it appears that *I* started it. My bad.

are there other inputs in your form?
 

SLEEPER5555

Golden Member
Aug 16, 2000
1,597
0
0
nope thats the whole page exactly what i posted, just trying to create a white backgound with a type here move to /typedinfo/
 

troytime

Golden Member
Jan 3, 2006
1,996
1
0
ok, change onsubmit="Javscript:gothere();" to onsubmit="Javascript:gothere();"

here's the problem. if your form is domain.com/form.html, it will only send user to a directory contained at that root level.
if user wants to go to domain.com/folder1/folder3/, they'll probably have to type that in.

as for the form submitting on the enter button, i've never found a sure fire way to make it work. (but i've never really spent a lot of time caring either)
 
sale-70-410-exam    | Exam-200-125-pdf    | we-sale-70-410-exam    | hot-sale-70-410-exam    | Latest-exam-700-603-Dumps    | Dumps-98-363-exams-date    | Certs-200-125-date    | Dumps-300-075-exams-date    | hot-sale-book-C8010-726-book    | Hot-Sale-200-310-Exam    | Exam-Description-200-310-dumps?    | hot-sale-book-200-125-book    | Latest-Updated-300-209-Exam    | Dumps-210-260-exams-date    | Download-200-125-Exam-PDF    | Exam-Description-300-101-dumps    | Certs-300-101-date    | Hot-Sale-300-075-Exam    | Latest-exam-200-125-Dumps    | Exam-Description-200-125-dumps    | Latest-Updated-300-075-Exam    | hot-sale-book-210-260-book    | Dumps-200-901-exams-date    | Certs-200-901-date    | Latest-exam-1Z0-062-Dumps    | Hot-Sale-1Z0-062-Exam    | Certs-CSSLP-date    | 100%-Pass-70-383-Exams    | Latest-JN0-360-real-exam-questions    | 100%-Pass-4A0-100-Real-Exam-Questions    | Dumps-300-135-exams-date    | Passed-200-105-Tech-Exams    | Latest-Updated-200-310-Exam    | Download-300-070-Exam-PDF    | Hot-Sale-JN0-360-Exam    | 100%-Pass-JN0-360-Exams    | 100%-Pass-JN0-360-Real-Exam-Questions    | Dumps-JN0-360-exams-date    | Exam-Description-1Z0-876-dumps    | Latest-exam-1Z0-876-Dumps    | Dumps-HPE0-Y53-exams-date    | 2017-Latest-HPE0-Y53-Exam    | 100%-Pass-HPE0-Y53-Real-Exam-Questions    | Pass-4A0-100-Exam    | Latest-4A0-100-Questions    | Dumps-98-365-exams-date    | 2017-Latest-98-365-Exam    | 100%-Pass-VCS-254-Exams    | 2017-Latest-VCS-273-Exam    | Dumps-200-355-exams-date    | 2017-Latest-300-320-Exam    | Pass-300-101-Exam    | 100%-Pass-300-115-Exams    |
http://www.portvapes.co.uk/    | http://www.portvapes.co.uk/    |