how to reload another browser window from a form (after insert/update)

I have created a scriptcase form (A) for maintaining appointments (table appointments).
I have a planboard (B) written in PHP (non scriptcase) that shows appointments in time.

After I insert or update (specific columns of) an appointment record from the scriptcase form (A), I want the planboard (B) to be reloaded automatically.

I tried it using scriptcase events OnAfterInsert and OnAfterUpdate but did not get it to work.

Any suggestions?

Re: how to reload another browser window from a form (after insert/update)

Can you provide the call you used to redirect?

Have you tried something like?
<?php
header( ‘Location: http://www.yoursite.com/new_page.html’ ) ;
?>

Re: how to reload another browser window from a form (after insert/update)

I want to reload Form A from form B (without parent/child relationship), this can be done using javascript http://codingforums.com/showthread.php?t=113902 (or is javascript not suitable here?)

But how can this reload be triggered from the other (scriptcase) form?

Re: how to reload another browser window from a form (after insert/update)

Are both forms on the screen at the same time? I am trying to ask what is your current approach now. What code did you use in your events. Did you try to redirect to the 2nd form, or are you trying to update the 2nd displayed form will both are visible.

Regards,
Scott.

Re: how to reload another browser window from a form (after insert/update)

They are both open and visible, though while working in the scriptcase form (A) the planboard that needs to be reloaded (B) is on the background (and should stay on the background after the reload).

Re: how to reload another browser window from a form (after insert/update)

I know this does not follow what you are asking since it uses a grid and does not perform an insert/update, but it may point you in a direction: (FormB is updated by navigating fromA.)
http://www.scriptcase.net.br/sistemas/v5/exemplos_pt_br/form55/form55.php

The key here is that you are using an iframe to display an updated formb and not have to reload the entire form.

Since you are loading a non-sc PHP, I an not sure if populating the Exit URL in the link properties would give you correct result. (see image on tutorial)

The idea is that once you hit save, it will then re-load formB in an iframe to see that changes you just made without having to reload formA, else you could just reload that entire page, but who wants that :wink:

Here is a search for populating the iframe manually.
http://www.webmasterworld.com/forum91/1793.htm (or google ‘PHP iframe’)

If none of this helps, I can try to create a sample after I put out a few fires.

Regards,
Scott.

Re: how to reload another browser window from a form (after insert/update)

Thanks Scott, but I’m still stuck for the reason that I don’t want to use an iframe. Formb (non-sc planboard) contains a large table containing all days of a year horizontally and rental ships vertically. By scrolling horizontally the user can see all bookings of all ships over a year. I (and my customer) explicitly want to keep this planboard in a seperate browser window/tab.

I found out that using javascript it is possible to reload a different browser window/tab:

FormA -> reload button


<html>
<head>
<script language='javascript'>
  function reloadplanboard(){
   var w=window.open("", "planboard"); //get handle of planboard
   w.location.reload(true); //reload it
  }
</script>
</head>
<body>
 <form onSubmit="reloadplanboard();">
 <input type="submit" value="reload planboard!"/>
 </form>
</body>
</html>

FormB -> page showing current time after clicking button in FormA


<html>
<head>
<script language='javascript'>window.name='planboard';</script>
</head>
<body>
<?php
echo "time: ".date('H:i:s');
?>
</body>
</html>

Maybe there’s a way to load/execute the code in formA from a SC form?

Re: how to reload another browser window from a form (after insert/update)

Vitor suggested to call reloadplanboard() by putting this code in OnAfterUpdate event:
echo “<script language=‘javascript’>reloadplanboard();</script>”;

Besides that I get an (unwanted) inline popup where an empty row is added each time I click no update, it has no effect…

Re: how to reload another browser window from a form (after insert/update)

I found a workaround:

In the onAfterInsert/Update/Delete I set a reload flag in the database to Yes. That’s all I’ll have to do in de Scriptcase form (A).

In the planboard (B) page there’s a new frame (not visible) that reloads each X seconds (javascript setTimeout). In every reload it checks (using PHP) the reload flag in the database. If the flag is Yes then this line is generated by the php:

echo "<br /><script language=javascript>reloadplanboard();</script>";

and also the flag is set to No. That’s all. Refresh seconds are stored in the database and can be updated by the administrator.

Probably not the nicest solution, but it works. Any suggestions for a better solution are welcome!

thanks.