Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Auto activate function

Status
Not open for further replies.

cumap

IS-IT--Management
Jul 9, 2007
268
US
hi all,

This is a task I need to do.
- a operation page that with all functionalities.
- a popup where user will fill in or select choices.
- after make all selections and have all info filled out, popup page will automatically close when submitted, and the opener (operation page) receive the form's info and automatically activate a specific function to process them.

The key here is the last step: automatically activate the function. Is there is way in js to do that?

I tried to move/copy those functions to the popup page and executed them when submitted, but the functions didn't work correctly due to some related data are collecting in the operation page.

Thanks!
 
Two ways:

1.
- On the opener, place a hidden text box and set an onblur event to execute a function:

<input type="hidden" id="myTbx" onblur="doIt();" />
- in the popup, create an onunload funtion that focuses on the parent text box and then use immediately blur it

Code:
<script language="javascript">
function foo() {
parent.document.getElementById("myTbx").focus();
parent.document.getElementById("myTbx").blur();
}
</script>
<body onunload = "foo();">
...
</body>


2.
- assign the pop up to an obj:

var myPopup = window.open(...)

- create a recurive function in your parent window that kicks out once the pop up is closed
Code:
function foo() {
 if myPopup.closed {
   doIt();
 } else { foo(); }
}


the second option could eat up a lot of processing power on the client so it is not recommended unless the pop up is closed within a couple of seconds




--------
GOOGLE is a great resource to find answers to questions like "how do i..."

If you don't know exaclty what you want to do or what to search one, try Google Suggest: --------
I have recently been semi-converted to ensuring all my code (well most of it) works in both javascript and non-javasc
 
Thank you vicvirk for your reply.

I'm on another project right now and will have a feedback for you or more questions (if needed) as soon as I get back.

Again, appreciated for your helping hand every time I stuck.:)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top