Click to See Complete Forum and Search --> : onsubmit location.href problems
I have a form in which people type a password it then takes them to the page with the name of the password (I add .html to it in the function). This works fine when you click the button but using the <form onSubmit=""> it just displays the value in the textbox after the address. as in c:\password.html?pass=ten. Why does it do this and is there a way to make it so that when I press enter it takes me to that page?
Thanks,
IxxI
EDIT: I've had this problem before and its not a location.href problem but an onSubmit problem.
Are you putting return false; in the onSubmit, too? That needs to be in there, otherwise it will run the function and submit the form, too.
khalidali63
05-22-2003, 08:08 AM
to me it sounds like you have method="post"
in the form element,if so make it method="get"
Actually, Khalid, that's backwards. If it's displaying the variables in the URL, it's using the GET method, which means he probably doesn't even have the method attribute in his form tag.
Just hit the submit or enter button:
function AnotherPage() {
window.location.href=document.myForm.requested.value+".html";
}
<form action="#" name="myForm" onsubmit="AnotherPage();return false;">
<input id="requested" type="text" /><br />
<button type="submit">Load Page</button>
</form>
It's that 'return false' again!
Thanks all,
it was the return false, should have seen it really :rolleyes:
IxxI