0

I have a form that once you select from a drop-down list and select submit, it is suppose to open up to a new window

Here is the code that is currently on the page and I think it needs to be completely wiped out or revised, it only works in IE and Firefox

<SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript"> 
//<!-- Hide JavaScript from older browsers 
//  Function to open a window
function windowOpen(window_url) {
   helpWin = window.open(window_url,'','toolbar=yes,status=no,scrollbars=yes,menubar=yes,resizable=yes,directories=no,location=no,width=350,height=400');
   if (document.images) { 
       if (helpWin) helpWin.focus()
   }
}
//  End script hiding --> 
</SCRIPT>

<FORM ACTION="/pls/prod/zp_process_sm_payment.pz_process_sm_payment" METHOD="POST"> 

<TABLE  CLASS="dataentrytable" SUMMARY="This table allows
                                                the user to select a
                                                valid term for
                                                registration
                                                processing."> 
<TR> 
<TD CLASS="delabel" scope="row" >Select a Term: </TD> 
<TD CLASS="dedefault"> 
<LABEL for=term_id><SPAN class=fieldlabeltextinvisible>Term</SPAN></LABEL> 
<SELECT NAME="term_in" SIZE="1" ID="term_id"> 
<OPTION VALUE="201040">Fall 2010
<OPTION VALUE="201030">Summer 2010
<OPTION VALUE="201020">Spring 2010
<OPTION VALUE="201010">Winter Mini 2010 (View only)
<OPTION VALUE="200940">Fall 2009 (View only)
<OPTION VALUE="200930">Summer 2009 (View only)
<OPTION VALUE="200920">Spring 2009 (View only)
<OPTION VALUE="200910">Winter Mini 2009 (View only)
<OPTION VALUE="200840">Fall 2008 (View only)
<OPTION VALUE="200830">Summer 2008 (View only)
<OPTION VALUE="200820">Spring 2008 (View only)
<OPTION VALUE="200810">Winter Mini 2008 (View only)
<OPTION VALUE="200740">Fall 2007 (View only)
<OPTION VALUE="200730">Summer 2007 (View only)
<OPTION VALUE="200720">Spring 2007 (View only)
<OPTION VALUE="200710">Winter Mini 2007 (View only)
<OPTION VALUE="200640">Fall 2006 (View only)
</SELECT> 
</TD> 
</TR> 
<TR> 
<TD COLSPAN="11" CLASS="deseparator">&nbsp;</TD> 
</TR> 
</TABLE> 
<INPUT TYPE="submit" VALUE="Submit"> 
</FORM>
Brad
  • 12,054
  • 44
  • 118
  • 187
  • 4
    Where does it not work and what happens or doesn't happen? – Pekka May 04 '10 at 18:11
  • And can you remove the `Hide JavaScript from older browsers ` part? I think technically, that constitutes a Syntax error. – Pekka May 04 '10 at 18:11
  • When I select submit, it will not open to a new window, like it should. Unfortunately I do not have access to the code to make appropriate changes, it was done by third-party. In some browsers it works, and some it does not. – Brad May 04 '10 at 18:14
  • @Pekka, fixed the syntax error :) – Jacob Relkin May 04 '10 at 18:15
  • @Jacob that's better :) @Brad those browsers will have an error console (At least, Chrome and Opera do) that will tell you what exactly is wrong. – Pekka May 04 '10 at 18:16
  • Take a look at this while you're at it, Brad: http://stackoverflow.com/questions/204813/does-it-still-make-sense-to-use-html-comments-on-blocks-of-javascript – Diodeus - James MacFarlane May 04 '10 at 18:23
  • 1
    can you show the code where `windowOpen` gets called? are you using the submit button at the end of your sample? because that's going to submit your form to the server too. – lincolnk May 04 '10 at 18:36

1 Answers1

1

Once you submit a form (on the same page), you lose control of the page. JavaScript execution stops while the browser waits for the new page to load.

You need to open your new window first, then submit the form.

I'm not sure it this is the issue without seeing the code for your form as well.

Diodeus - James MacFarlane
  • 112,730
  • 33
  • 157
  • 176
  • I don't think he is actually submitting the form?... But we can't know for sure without seeing it. – Pekka May 04 '10 at 18:17