Javascript: Open Form in New Window to all POST

  • devilwood
  • Silver Member
  • Silver Member
  • User avatar
  • Posts: 437

Post 3+ Months Ago

This is obviously not as simple as the first 100 google results appear to be.

Code: [ Select ]

function startprocess()
{
var url = "process1.php";     
win = window.open(url, "CSC", "width=900,height=750,status=no,resizable=yes,scrollbars=yes,menubar=no,toolbar=no");
}



<a href="#" onclick="startprocess();"><img src="images/processcard.png" title="Start Process" /></a>
  1. function startprocess()
  2. {
  3. var url = "process1.php";     
  4. win = window.open(url, "CSC", "width=900,height=750,status=no,resizable=yes,scrollbars=yes,menubar=no,toolbar=no");
  5. }
  6. <a href="#" onclick="startprocess();"><img src="images/processcard.png" title="Start Process" /></a>



That image link fires the popup window the way I need it in Chrome and IE. But when I need to POST some variables...

Code: [ Select ]

function submitform(f)
{
 document.forms[f].submit();
}

function resumeprocess(w)
{
var url = "resumeprocess.php";     
win = window.open(url, w, "width=900,height=750,status=no,resizable=yes,scrollbars=yes,menubar=no,toolbar=no");

}

<form name='$formname' method='post' action='resumeprocess.php' target='CSC' onsubmit="resumeprocess(this.target);"><input type='hidden' name='updatekey' value='$processid'></form><a href='#' onclick="submitform('$formname');" title='Click to Edit'>$processid</a>
  1. function submitform(f)
  2. {
  3.  document.forms[f].submit();
  4. }
  5. function resumeprocess(w)
  6. {
  7. var url = "resumeprocess.php";     
  8. win = window.open(url, w, "width=900,height=750,status=no,resizable=yes,scrollbars=yes,menubar=no,toolbar=no");
  9. }
  10. <form name='$formname' method='post' action='resumeprocess.php' target='CSC' onsubmit="resumeprocess(this.target);"><input type='hidden' name='updatekey' value='$processid'></form><a href='#' onclick="submitform('$formname');" title='Click to Edit'>$processid</a>


Sorry, this is the last variation I've tried with setting action, target, and url variables in the php and javascript. The above in Chrome opens a new tab instead of a popup. In IE it opens a new popup but has all the menubars like a normal window... The whole reason I need a javascript popup is because I want the content I'm displaying free from the addressbar, searchbar, etc.

It seems I can't get a form to submit in order to post variable to a popup window that has no browser menus. It's like it's not reading the properties parameter in the javascript. Additionally, the resumeprocess.php page takes the posted variables and then uses a header(location:) line to forward to process1.php. I don't know why this would be causing the window problems.

Is this a bug with POSTING to a popup window and is there a way to get a slimmed-down browser window with a form?
  • devilwood
  • Silver Member
  • Silver Member
  • User avatar
  • Posts: 437

Post 3+ Months Ago

I figured if I kept doing every variation I'd get it working.

Really three things I had wrong and most of my problem was coming from using an <A> link to submit the form.

1. Remove the onsubmit call
2. combined the resumeprocess with the submit function. I was obviously submitting the information before the blank page was created.
3. URL needs to be blank

** The popup has to be created first before submitting the data. I'm not sure how the onsubmit works cause that fires after the form is submitted. The target name of the form and the window.open method tells the form data what window to fill.
** If anyone wants to elaborate on that please feel free.

Code: [ Select ]

function submitform(f)
{

var url = "";     
win3 = window.open(url, 'CSC', "width=900,height=750,status=no,resizable=yes,scrollbars=yes,menubar=no,toolbar=no,location=0");

document.forms[f].submit();
 
}
  1. function submitform(f)
  2. {
  3. var url = "";     
  4. win3 = window.open(url, 'CSC', "width=900,height=750,status=no,resizable=yes,scrollbars=yes,menubar=no,toolbar=no,location=0");
  5. document.forms[f].submit();
  6.  
  7. }

Post Information

  • Total Posts in this topic: 2 posts
  • Users browsing this forum: No registered users and 82 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
cron
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.