Forum Moderators: open

Message Too Old, No Replies

Open pop up whether they click or press enter

Actually working good with click... not enter...

         

silverbytes

1:43 pm on Apr 29, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I need to open a new window in a form confirmation window.

I actually have in my html:

<input name="okbot" type="image" id="okbot"
onClick="MM_openBrWindow('loading.htm','oknews','width=380,height=133')"
src="img/okbot.gif" alt="Enviar" align="middle" width="20" height="14"
border="0" >

But that works if the user clicks the button, not if the user press "enter"
key.

Is there anyway to make the pop up confirmation window appear `b]wether they click or press enter[/b] after filling the email field?

coopster

3:20 pm on Apr 29, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



You might use the
onsubmit
event handler on the
<form>
element and setup your own function for form submittal...


...
function checkForm(form, evt) {
if (do I want to submit the form?) {
return true
} else {
return false
}
...
<form action="process.php" method="post" onSubmit="return checkForm(this, event)">

silverbytes

5:37 pm on Apr 29, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Thank you! However I don't understand much that function and seems to be a rough example (does actually work that code?)

I guess the first part should be in the head tag
and the rest in the submit.

the part: (form, evt) should say (form, event)
or must I replace that with any particular data?

I appreciate your help about it!

coopster

8:07 pm on Apr 29, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Yes, it is a rough example, showing you the concept.
And yes, the first part should be in the head tag within your <script> tags, and the event handler goes on the <form> tag as shown in the example.

The

(this, event)
on the
onsubmit
event handler of the <form> are javascript keywords.
this
refers to the related element of the document, in this case the <form>.
event
will grab the keyboard event, which you may or may not be concerned about. Both values get passed to the javascript function where they take on whatever variable names you have assigned in the functions parameter list, in this case
(form, evt)
so that within the function you can refer to them by this variable name.