467,891 Members | 1,836 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 467,891 developers. It's quick & easy.

How to submit form to pop-up window *when* changing a select, etc

Hello,

I have a form that submits it's values to a pop-up window. I've
simplied the code:

<form name="formname" action="action.php" target="windowName"
method="post" onsubmit="window.open('', this.target,
'dialog,modal,scrollbars=yes,resizable=no,width=30 0,height=200,left=362,top=284');">
It works perfectly fine when changing form data and then pressing the
submit button. It submits the form to a pop-up window which is 300
pixels wide and 200 pixels high as expected.

However, I would like it so that when somebody changes a <select>, the
form is automatically submitted. The select code is:

<select name="test" onchange="formname.submit();">

On changing the value of the select, the form is submitted to a new
window that is full screen. It is not sent to a pop-up window as
should be.

How do I correct this?

Thanks.
Jul 20 '05 #1
  • viewed: 24244
Share:
3 Replies
In article <fn********************************@4ax.com>, je**@dnuk.com writes:
<select name="test" onchange="formname.submit();">

On changing the value of the select, the form is submitted to a new
window that is full screen. It is not sent to a pop-up window as
should be.

How do I correct this?


Move your onsubmit to a function, call the function onSubmit of the form and
onSubmit of the select name. Return false and allow the function to submit the
form.
--
Randy
Jul 20 '05 #2
On 06 Nov 2003 21:35:12 GMT, hi************@aol.com (HikksNotAtHome)
wrote:
Move your onsubmit to a function, call the function onSubmit of the form and
onSubmit of the select name. Return false and allow the function to submit the
form.


Hello Randy,

I'm not sure what you mean. I have this Javascript at the top of the
page:

<script language="JavaScript" type="text/javascript">
function onSubmit()
{
window.open('', this.target,
'dialog,modal,scrollbars=yes,resizable=no,width=30 0,height=200,left=362,top=284');
}
</script>
And modified the form and selects to this:

<form name="formname" action="action.php" method="post"
onsubmit="onSubmit;">

<select name="select" onchange="onSubmit;">
What else is required?

Thanks for your assistance.

Jul 20 '05 #3
je**@dnuk.com wrote:
[...] hi************@aol.com (HikksNotAtHome) wrote:
Move your onsubmit to a function, call the function onSubmit of the form and
onSubmit of the select name. Return false and allow the function to submit the
form.
[...]
<script language="JavaScript" type="text/javascript">


<script type="text/javascript">

as written before.
function onSubmit()
Although JavaScript is case-sensitive,
you do not want to call it `onSubmit'.
{
window.open('', this.target,
'dialog,modal,scrollbars=yes,resizable=no,width=30 0,height=200,left=362,top=284');
`this.target' is wrong here since `this' refers to the global object in
an ordinary function, not to the Form object as supposed. To reference
the Form object, pass `this' as argument (here: o) in the event handler
and use `o.target' instead.

And I know neither the `dialog' nor the `modal' option. Maybe IE supports
them but it has other methods for dialogs. What you are looking for may be
`dependent'[`=yes'], working only in Netscape 4 and Mozilla/5.0.
}

And modified the form and selects to this:

<form name="formname" action="action.php" method="post"
onsubmit="onSubmit;">
That is neither a function call nor do you return the expected value.
You need to cancel the submit event:

<form ... onsubmit="return foobar(this);">

then you must use `return false;' in the foobar() function. You can
also write

<form ... onsubmit="foobar(this); return false;">
<select name="select" onchange="onSubmit;">
Do not do this. You burden[1] keyboard users to select something.
What else is required?


See above.
PointedEars
___________
[1] What is the appropriate word for the opposite of `(to) ease'?
Jul 20 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by Bruce Duncan | last post: by
5 posts views Thread by LevaOpaki | last post: by
6 posts views Thread by tencip | last post: by
7 posts views Thread by David T. Ashley | last post: by
4 posts views Thread by j1dopeman | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.