Sunday, May 19, 2024
 Popular · Latest · Hot · Upcoming
126
rated 0 times [  131] [ 5]  / answers: 1 / hits: 168345  / 13 Years ago, fri, december 23, 2011, 12:00:00

This seemed so trivial when I started off with it! My objective is this:




  • When user clicks on a button, open up a form in a new window.

  • Once the form is submitted, close the popup and return to the original page. The reverse order is fine too - i.e., I am okay if the popup is closed and then the form submits.



Here's how I'm doing this:



<form action=/system/wpacert method=post enctype=multipart/form-data onsubmit=return closeSelf() name=certform>
<div>Certificate 1: <input type=file name=cert1/></div>
<div>Certificate 2: <input type=file name=cert2/></div>
<div>Certificate 3: <input type=file name=cert3/></div>

<div><input type=submit value=Upload/></div>
</form>


and the Javascript looks like this:



<script type=text/javascript>
function closeSelf(){
self.close();
return true;
}
</script>


This seems to work fine on IE8 and Chrome; but Firefox refuses to submit the form; it just closes the popup. What might I be doing wrong?



EDIT:



Had forgotten to post the code the opens the popup. Here it is:



<div><input type=submit value=Upload Certificates onclick=popupUploadForm()/>




And the corresponding javascript:



function popupUploadForm(){
var newWindow = window.open('/cert.html', 'name', 'height=500,width=600');
}

More From » html

 Answers
45

I have executed the code in my machine its working for IE and FF also.



function closeSelf(){
// do something

if(condition satisfied){
alert(conditions satisfied, submiting the form.);
document.forms['certform'].submit();
window.close();
}else{
alert(conditions not satisfied, returning to form);
}
}


<form action=/system/wpacert method=post enctype=multipart/form-data name=certform>
<div>Certificate 1: <input type=file name=cert1/></div>
<div>Certificate 2: <input type=file name=cert2/></div>
<div>Certificate 3: <input type=file name=cert3/></div>

// change the submit button to normal button
<div><input type=button value=Upload onclick=closeSelf();/></div>
</form>

[#88407] Wednesday, December 21, 2011, 13 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
raveno

Total Points: 453
Total Questions: 92
Total Answers: 92

Location: France
Member since Thu, Oct 27, 2022
2 Years ago
raveno questions
;