Forum Moderators: coopster

Message Too Old, No Replies

Passing variables after window close

         

woldie

2:32 pm on Sep 27, 2004 (gmt 0)

10+ Year Member



Hello,

I've got a wee problem I'm having difficulty with. What I have is a form whereby when you click on this button a pop-up calendar appears.

What I'm trying to achieve is that when you do click on a date it closes the window and then refreshes the parent window and displays the date selected. The code below is what I have, but this doesn't work.

Any ideas?

Cheers. :o)

Code:

<table>
<form name="myform" method="post" action="callback_date.php" target="mypopup" onsubmit='window.open("",this.target,"scrollbars=yes,width=650,height=580");return true;' >
<tr>
<td class="labelcell">Salesman</td>
<td>Sales</td>
<td><input type="submit" name="status" value="Callback date" class="button"></td>
<td class="labelcell"><!-- This is where it should populate the date selected -->
<? echo $callbkdate?></td>
</tr>
<input type="hidden" name="bwid" value=<? echo $bwid;?>>
<input type="hidden" name="source" value=<? echo $source;?>>
</form>
</table>

callback_date.php

This is a snippet of the code:

echo "<td><a href=main-sales.php?bwid=$bwid&callbkdate=$link_date&source=$source onclick=\"window.opener.location.reload();self.close();return false;\"> $day </a></td>";

As you can see I'm using javascript, but I'm hoping to pass the variable callbkdate so that it should populate, but it ain't.

Thanks.

Birdman

3:15 pm on Sep 27, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Instead of reloading the opener, try redirecting it:

echo "
<td>
<a href=\"javascript: window.opener.location.href='main-sales.php?bwid=$bwid&callbkdate=$link_date&source=$source; self.close();'\"> $day </a>
</td>";

My appologies if the code above doesn't work, I did not test it.

woldie

4:28 pm on Sep 27, 2004 (gmt 0)

10+ Year Member



Thanks Birdman,

This is the code, I've used:

echo "<td><a href=main-sales.php?bwid=$bwid&callbkdate=$link_date&source=$source onclick=\"window.opener.location.href.reload();self.close();return false;\"> $day </a></td>";

This works in the child window, and populates the date, but it doesn't close the window and refresh the parent, so nearly there with it.

Thanks

Birdman

4:52 pm on Sep 27, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Ah, I just tested the code I posted and there was an error in it :(

A misplaced single-quote is what killed it.

Try this instead:

echo "
<td>
<a href=\"javascript: window.opener.location.href='main-sales.php?bwid=$bwid&callbkdate=$link_date&source=$source'; self.close();\"> $day </a>
</td>";

woldie

7:36 am on Sep 28, 2004 (gmt 0)

10+ Year Member



Cheers Birdman, that did the trick! Thanks for your patience, works like a dream :o).

Top man :o)

Woldie.