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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Having problems with using flash to set variables in flash 1

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
Hi. I am currently trying to make a popup flash calendar that sends a value to text field on the window that opened it.

It is working, but I’m having a few problems.

The first problem is fairly big. Once someone has used the flash calendar to send the date to the text field it closes the window with the flash in it and leaves the new value in the form. – great!

But, the people that I am doing this for would like to add some functionality. If, once the user has their date value – and the want to change it – clicking on the date will load the flash window again, but instead of starting on today’s date it starts on the date that is in the text field.

So, this will involve sending a variable (the contents of the text field to the popup flash window.

This is where the problems starts:

Initially I used the code:


FIRST VERSION
function newwin()
{
var win = window.open("cal.html","calendar","toolbar=0,,titlebar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,width=275,height=325");
win.document.calendar.SetVariable("sentdate", document.forms[0].mydate.value);
}

This comes up with the error:

Document.calendar is not and object.

But, if I add the following, it does send the contents of the field to the flash window:

SECOND VERSION
function newwin()
{
var win = window.open("cal.html","calendar","toolbar=0,,titlebar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,width=275,height=325");
alert(win.document.location);
win.document.calendar.SetVariable("sentdate", document.forms[0].mydate.value);

}

The first version can be seen at:

The second version

The small thing that I am trying to do is call the close window function if the user clicks anywhere other than the date text box. Or to make the flash popup window always on top.

Please feel free to view the source to see all the ways I’m going wrong.

Cheers if you can help in any way.

Matt

 
! this is weird !! just adding the alert(..) part makes it work !! i've seen that already but i don't remember how i solved it :-(
maybe you could try win.document.location.reload() instead of alert(win.document.location) but i would be surprised if it makes it work !
about the &quot;call the close window function if the user clicks anywhere other than the date text box&quot;, you could try <body onclick=&quot;close_function()&quot;> but here again i'm not 100% sure
about making the popup window modal (&quot;to make the flash popup window always on top&quot;) i don't even know if it's feasible in javascript.
 
Hi, thanks for your response. Do you have an example of setting a variable in a popup window, and back again?

Matt
 
i don't know about flash and adressing it
but setting a variable in a popup is just the same as setting one in a &quot;normal&quot; window
----
sending the var to the popup / to any window
----
2 solutions :
-> submit a form !! the action (target page) should equal the popup. For instance :
var win = window.open(&quot;cal.html&quot;,...);
your_form_on_the_calling_page.action=win;
your_form_on_the_calling_page.submit();
or something much like that

-> add the var to the url !!
var win = window.open(&quot;cal.html?sentdate=document.forms[0].mydate.value&quot;, ...)

----
getting the var from the popup
----
there must be a better solution but the only one i found is :
(this code goes in the popup window - becareful to call this code BEFORE closing the popup !)
...
// to set a variable in the opening window with a variable defined here
opener.a_var=the_local_var;
// to call a function in the opening window with a variable defined here
opener.a_func(the_local_var);
...





 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top