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

J

jeff

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=300,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.
 
J

jeff

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=300,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.
 
T

Thomas 'PointedEars' Lahn

[...] [email protected] (HikksNotAtHome) said:
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=300,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

<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'?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top