soryy, that shluld have been add it to the processing page code, make it the last line.
Main Topics
Browse All TopicsI pop-up a form window from my main page.
On submit it gets form validation then should close and submit the data back to the main window.
I cant get it to do so without skipping the form validation though :-(
main.cfm - ( pops up ) -> myForm.cfm - ( targets main pg ) -> myForm_handler.cfm - ( relocates to ) ->main.cfm
--------------------------
This does the form validation but doesnt close the window ::
<form name="form1" method="post" action="modTitle_h.cfm" target="main" onSubmit="return validateForm(this);self.cl
<input type="Submit" name="Enter" value="Enter"/>
</form>
--------------------------
I also tried the following but it skips the form validation::
<form name="form1" method="post" action="modTitle_h.cfm" target="main" onSubmit="return validateForm(this);">
<input type="button" name="Enter" value="Enter" onClick="document.form1.su
</form>
--------------------------
I also tried closing the opener from myForm_handler.cfm but i can't seem to reference it from there...
... Just need the form to submit and close the pop up window upon validation = True
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
I tried that and it doesnt work ...
[ on the form page ]
I pasted it above and it just skips the form validation...
[ on the processing page ]
If I put window.close(); on the processing page it closes the one that should contain the results.
Im pretty sure this is due to the target='main' but i need the results to show in the main window.
if you are refreshing the parent pag there is no way to close the child, once the processing page loads thereference to the child is lost, you canb try adding this to teh form page but its not 100%
at teh end of teh form validate add this line (on success of course)
setTimeout("window.close()
Hmm, any suggestions to work around this?
The form allows a user to change the title / description of a listing then updates the main page ...
Is it possible to maybe do like an onBlur event or something so that if the pop-up window is put into the background ( not the top window / focus ) it auto closes...
I hope I understand what you want to do: be able to editate a title and a description from a popup
tell me about this:
mainpage (home.html)
<html>
<body>
<div id="name" style="font-weight: bold;">My Default title</div><br/>
<div id="description">My amazing comment</div>
<a href="#" onclick='window.open("popu
</body>
<html>
popup (popup.html)
<html>
<body>
<script>
function submit()
{
var myName=document.getElement
var myDescription=document.get
var dataChecked = false;
//put the logic to check if the data is ok (here, it will be true)
dataChecked = true;
if (dataChecked)
{
opener.document.getElement
opener.document.getElement
window.close();
}
}
</script>
name: <input type="text" id="name" /><br />
description: <input type="text" id="description" /><br />
<a href="#" onclick="submit()">click to save</a>
</body>
<html>
Its more like ::
( viewMtg.cfm )
<html>
<body>
<a href="X" onClick="window.open(' ','name4','resizable=no,sc
<form name="modTitle" action="modTitle.cfm" method="post" target="name4">
<input type="hidden" name="R_ID" value="#R_ID#">
</form>
</body>
</html>
( modTitle.cfm)
<html>
<script>
window.opener.name="main";
</script>
<script src="Validation/FormValida
<body>
<form name="form1" method="post" action="modTitle_h.cfm" target="main" onSubmit="return validateForm(this);self.cl
... some form vars...
</form>
</body>
</html>
( modTitle_h.cfm )
<html>
<body>
... Process the form ...
<CFLocation url="viewMtg.cfm?R_ID=#for
</body>
</html>
Seperately my form validation works fine, and the window close work fine...
Combining them so the window closes after validation is what does not work.
My program interacts with databases in the background so just changing the values on the opener page does not work for me :
--------------------------
if (dataChecked)
{
opener.document.getElement
opener.document.getElement
window.close();
}
--------------------------
My guess is that the ordering of your onSubmit code is the problem.
>> onSubmit="return validateForm(this);self.cl
Logically, if you validate first & return the result, the next statement (close window) will never run because you just said to "return" or exit the whole block of code for that javascript event. If you don't need the return value, taking out "return" might work for you like:
onSubmit="validateForm(thi
If you put window close statement first, the window will likely close before you can validate the results.
Another workaround could be to put validate function as a function call within another function like this:
onSubmit="processForm(this
//then in the code for processForm:
function processForm(theForm){
var result = validateForm(theForm);
//do whatever you need with "result"
self.close(); // or window.close();
}
so here is the process you are using:
main.cfm - ( pops up ) -> myForm.cfm - ( targets main pg ) -> myForm_handler.cfm - ( relocates to ) ->main.cfm
on myForm.cfm (the popup) you will have your form
<form name="form1" method="post" action="modTitle_h.cfm" target="main" onSubmit="return validateForm(this);">
<input type="text" id="myNewTitle" />
<input type="Submit" name="Enter" value="Enter"/>
</form>
the javascript function validateForm will return true or false is the data is correct or not
It the data is correct, then the popup will submit the data to modTitle_h.cfm, this page will record the data in DB and when it is done and if the recording has been working (you can know that by getting the value returned by the CFM function you called), you display the following code in the page:
<script>
opener.location.reload(tru
self.close();
</script>
so the pop up will close itself and the main page will reload and display the data updated.
if the SQL has not been working you can display an error message
LeeKowalkowski,
Thanks for your comment. I debated a while on how to close this. Let me elaborate and then feel free to let me know your recommendation if you still object. Please keep in mind the points I mention though.
First, there are only 50 points. At most I can accept 2 comments (20 points min required).
From the last comments the Asker posted it seems like he was helped by the comment I suggested and decided to change what he was doing. The expert pointed out the problem trying to refresh, close, etc.
Finally I do think there were other good posts here but the lack of response makes me think I am right in what I just said (see last paragraph). If there were more points or a second standout comment then I would've suggested a split.
I hope these details help. Let me know if you or anyone has an objection. Please be specific in what you recommend though. I can't just split among all experts. Thanks for your participation and help here though no matter how this is closed.
b0lsc0tt
EE Cleanup Volunteer
Hey, Sorry it took so long to get back on here... Broke a few bones and was out for a while...
I ended up getting rid of the pop-up so yeah, Jester_48's answer was the closest solution for me ::
--------------------------
"if you are refreshing the parent pag there is no way to close the child, once the processing page loads thereference to the child is lost, you canb try adding this to teh form page but its not 100%"
--------------------------
Thanks,
~Stu :-)
Business Accounts
Answer for Membership
by: Jester_48Posted on 2007-10-04 at 13:41:33ID: 20017683
at the end of the validation, if there is no error, execute this line
window.close();
thats it