Forum Moderators: open
Let me explain.
One field form with SUBMIT button.
The visitor is at www.example.com
They enter "text" into the form field and click SUBMIT.
The code redirects them to www.example.com/text
Thank you for your help.
[edited by: tedster at 11:07 pm (utc) on Oct. 23, 2008]
[edit reason] switch to example.com - it can never be owned [/edit]
<form action="" method="">
<fieldset>
<legend>The form</legend>
<input type="text" id="addy">
<input type="button" id="theButton" value="Go!">
</fieldset>
</form><script type="text/javascript">
document.getElementById('theButton').onclick = function(){
document.location.href=document.getElementById('addy').value;
}
</script>
However, when I try to replace type="button" with type="image" and the neccessary info to get my image to be viewed, it quits working? Why?
Also, when you hit the "Enter/Return" on the keyboard, it doesn't work, but if you click the button with the mouse it does. Why?
Your help is greatly appreciated.
type="image" will trigger the form action so if you want to use onclick you should use type="button". if you need a custom image just use the <img> tag.
enter/return on a form field will also trigger the form action, if you put the focus (tab to) the button then press enter/return it should act as you expect.