• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 234
  • Last Modified:

submit form to new window

I would like to submit the form to a new page in a new window from a function call, but it is not working.
I can't see what I may be missing here??!!

function submitForm(){
var newwindow;
var objForm = document.forms['form1'];
newwindow=window.open('reminder.asp','reminder','height=600,width=600');
objForm.action = "newwindow"
return true;
}


IN HTML:
<%
' IF TODAYS DATE IS > PROJECTED DATE OR NO RECORD RETURNED>>>>DISPLAY POPUP REMINDER
if strDate > ProjectedDate then %>
                                    
<script language="javascript">
      return submitForm()
</script>
<%
else
if projectedRS.EOF or projectedRS.BOF then %>
script language="javascript">
      return submitForm()
</script>
<%
else
      'do nothing stay here
end if
end if
%>

THANKKKSSSSS!!!!!!!
0
jhmoen
Asked:
jhmoen
  • 6
  • 4
  • 4
  • +1
1 Solution
 
NETTY4Commented:
In the <form> tag add the target attribute like this:

<form name="form1" target="_blank">

That's all.

0
 
NETTY4Commented:
And if you want to control the size of the new window, then do like this:


function submitForm(){
var newwindow;
var objForm = document.forms['form1'];
newwindow=window.open('reminder.asp','reminder','height=600,width=600');
objForm.target = "reminder";   // second parameter of window.open() is window name and you can use it as target //
objForm.action = "newwindow"
return true;
}

0
 
dominik_znidarCommented:
Hi.

To open submit a form to a new window, you must use target to do this.

So in your case add target="reminder" to your form tag. You can ofcourse to this in javsacript too. objForm.target="reminder";
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
jhmoenAuthor Commented:
I already have a javascript section at the top of my page within the html body...do I still need this code again:
<script language="javascript">
     return submitForm()
</script>


I have tried what you said, but the window does never popup.
investigating now.
0
 
dominik_znidarCommented:
Try this:

: IF CONDITIONAL TRUE ->
window.onload = submitForm();
0
 
dominik_znidarCommented:
if it doesn't work try like this : window.onload = submitForm;
0
 
jhmoenAuthor Commented:
I get:
Error: obj is not defined

the error line it gives me is not correct, so I am unsure where to look:
function submitForm(){
var newwindow;
var objForm = document.forms['form1'];
newwindow=window.open('reminder.asp','reminder','height=600,width=600');
obj.Form.target = "reminder"
objForm.action = "newwindow"
return true;
}
0
 
jhmoenAuthor Commented:
Cool!! I got it, that window.onload code worked!

Offhand, do you know a way of getting around popup blockers...in other words, I was getting blocked as well with the firefox blocker, then allowed it, and there were no problems.  I need my users to get this message on the popup browser window, but if they, like me, have a popup blocker installed then they won't ever see it.

Any Ideas?

0
 
dominik_znidarCommented:
sory, don't know.

As far as I know this type javascirpts are not welcome at users around world. Specialy me.

So for the future, if you use popups, show them on mouse cliks, not on page loads.
0
 
jhmoenAuthor Commented:
I thought I had it, but not quite.
The form is not submitting.  In other words, the two hidden textfields are not being passed.  Could it be because of the the window.onload = submitForm(); code?

Not sure why the fields are not being passed.  Other than that the popup seems to work well.

ANy ideas?
0
 
ZylochCommented:
I am not sure exactly, but unless it is extremely necessary to have the window at 600 by 600, I will not recommend using window.open. Javascript is absolutely fine as most users will have Javascript enabled or can enable their Javascript, however, I will stick with what the other people said about targets. Even if you want to set via Javascript for the second submit, you can still use something like:

submitForm(frm) {
   frm.target = "_blank";
   frm.action = "newwindow.asp";
   frm.submit();
}
0
 
jhmoenAuthor Commented:
So then what does the javascript call to the function look like in the html:

This is what I have:
.....
if projectedRS.EOF or projectedRS.BOF then %>
      <script language="javascript">
            window.onload = submitForm();
      </script>
<%
else
.....

???
using: return submitForm();
does not work
0
 
NETTY4Commented:
Like this:

if projectedRS.EOF or projectedRS.BOF then %>
     <script language="javascript">
          window.onload = submitForm;
     </script>
<%
else
0
 
jhmoenAuthor Commented:
I get error:
"frm has no properties"


function submitForm(frm){
frm.target = "_blank";
frm.action = "reminder.asp"
frm.submit();
}

USING THIS in HTML:
<script language="javascript">
window.onload = submitForm();
</script>
0
 
ZylochCommented:
You need:

window.onload = submitForm(document.forms["formname"]);

where formname is the name of your form.
0
 
NETTY4Commented:
You need:

<script language="javascript">
window.onload = function(){submitForm(document.forms[0])};
</script>

Or this:

<script language="javascript">
window.onload = new Function("submitForm(document.forms[0])");
</script>


Where you have not to care about your form's name.

0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 6
  • 4
  • 4
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now