• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

html form help

SLEEPER5555

Golden Member
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?
 
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?
 
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?
 
<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>
 
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
 
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?
 
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.
 
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?
 
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?
 
nope thats the whole page exactly what i posted, just trying to create a white backgound with a type here move to /typedinfo/
 
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)
 
Back
Top