Hi there guys. I’ve been reading the posts on this forum for a while, and realised that you may be able to help me with a problem I’ve been having!
My problem is this: I want to, using JavaScript, when one form is submitted (using the enter key), I want to submit a different form. My code looks something like this:
[code=html]<form action=”#” id=”visform”>
<input type=”text” name=”username” />
<input type=”password” name=”password” />
</form>
<form action=”login.php” id=”hidform”>
<input type=”hidden” name=”hiduname” />
<input type=”hidden” name=”hidpass” />
<input type=”submit” value=”Submit” />
</form>
Using JavaScript, when the second form is submitted, I copy over the values from the first form to the second form, doing some hashing on the way. This method works fine, apart from the fact that I cannot submit on an enter key press if the cursor is currently inside one of the text fields. I’ve tried the following onsubmit event handler of the visform:
[CODE]onsubmit=”document.getElementById(‘hidform’).submit();”
but since the first form doesn’t have a submit button of its own, this does nothing, and including a hidden submit button only submits the first form on enter, not the second one.
Any / all help would be appreciated! I realise that all my sites should run fine with JavaScript disabled, but this is a private one being used by only a few people, so the necessity to have JavaScript on isn’t a big one. Thanks in advance for the help!