Solved

flash form data to javascript popup

Posted on 2006-07-06
9
254 Views
Last Modified: 2008-03-10
Hello-

Is there a way to open a window using javascript and pass flash form data to that window? I tried this, but it didn't work in IE (I think the resulting url was too long):

var urlString = "contact_confirm.php";
urlString += "?first_name="+first_name; (this is actually much longer with more data)

getURL("javascript:launchwin('"+urlString+"','popupFormConfirmation','width=600,height=700,left=60,top=60,toolbar=No,location=No,scrollbars=No,status=No,resizable=No,menubar=No,fullscreen=No');popupFormConfirmation.focus();void(0);");

Here's the JavaScript:
<SCRIPT LANGUAGE="JavaScript"> var javascript_version = 1.0;</SCRIPT>
<SCRIPT LANGUAGE="JavaScript1.1">  javascript_version = 1.1;</SCRIPT>
<SCRIPT LANGUAGE="JavaScript">
var newwin;
function launchwin(winurl,winname,winfeatures)
{
      //This launches a new window and then
      //focuses it if window.focus() is supported.
      newwin = window.open(winurl,winname,winfeatures);
      if(javascript_version > 1.0)
      {
            //delay a bit here because IE4 encounters errors
            //when trying to focus a recently opened window
             setTimeout('newwin.focus();',250);
      }
}
</SCRIPT>

Thanks for any help!!
0
Comment
Question by:spoakes
  • 5
  • 4
9 Comments
 
LVL 34

Expert Comment

by:Aneesh Chopra
ID: 17055762
Hi,

I have uploaded a sample, download it here
http://www.4shared.com/file/2391446/5499159/postdatatopopup.html

Rgds
Aneesh
0
 

Author Comment

by:spoakes
ID: 17056084
Hi Aneesh-

This looks really helpful - thanks!

Question (I'm new at php): how can I break up the data once I get it into the pop up? The popup alllows users to confirm their submission. I'd like to use a format like this:

First Name: <?php echo $first_name; ?><br>
Last Name: <?php echo $last_name; ?><br>
Phone: <?php echo $phone; ?><br>

I adapted the actionscript you sent to look like this:

var urlString = "?first_name="+first_name+""&last_name="+last_name... ect.
getURL("javascript:sendData('"+urlString+"')");
0
 
LVL 34

Expert Comment

by:Aneesh Chopra
ID: 17056189
why dont you send three different variables from flash and add three hidden field in html form, so that you can get all three variables individually through post

i feel this will make more sense
let me know if you have any confusion in this concept
0
ScreenConnect 6.0 Free Trial

Discover new time-saving features in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI, app configurations and chat acknowledgement to improve customer engagement!

 
LVL 34

Expert Comment

by:Aneesh Chopra
ID: 17056199
as per above suggestion..

 flash will pass 3 parameters to "sendData" functions
similarly javascript function "sendData" will also gets updated and receive 3 parameters
function will update 3 hidden field value using 3 received values.
0
 

Author Comment

by:spoakes
ID: 17056252
OK, so if I understand correctly, I can add these hidden fields to the html form:

<input type="hidden" name="first_name" id="first_name" value="" />
<input type="hidden" name="last_name" id="last_name" value="" />
<input type="hidden" name="phone" id="phone" value="" />

and create three separate js functions like this:

sendData= function(first_name)
{
      document.myForm.first_name.value = first_name;
      //
      document.myForm.onsubmit();
      document.myForm.submit();
}

sendData= function(last_name)
{
      document.myForm.last_name.value = last_name;
      //
      document.myForm.onsubmit();
      document.myForm.submit();
}

sendData= function(phone)
{
      document.myForm.phone.value = phone;
      //
      document.myForm.onsubmit();
      document.myForm.submit();
}

sorry if I'm being dense.
0
 
LVL 34

Expert Comment

by:Aneesh Chopra
ID: 17056286
first part is correct as you understood..
following is correct:
-------------
<input type="hidden" name="first_name" id="first_name" value="" />
<input type="hidden" name="last_name" id="last_name" value="" />
<input type="hidden" name="phone" id="phone" value="" />
--------------

but you dont need seperate functions, you can simply add two additional parameter to existing function
here is example:
-------------
sendData= function(first_name, last_name, phone)
{
     document.myForm.first_name.value = first_name;
     document.myForm.last_name.value = last_name;
    document.myForm.phone.value = phone;
     //
     document.myForm.onsubmit();
     document.myForm.submit();
}
-------------

in addition, from flash you will call above function with 3 parameters

0
 

Author Comment

by:spoakes
ID: 17056309
Got it. OK, I think this is my last question:

This is the actionscript?

---------

getURL("javascript:sendData('first_name,last_name,phone')");

---------
0
 
LVL 34

Accepted Solution

by:
Aneesh Chopra earned 350 total points
ID: 17056337
no not like that....

if you have textfield than ti should be like this:

-------------
getURL("javascript:sendData('"+text1.text+"','"+text2.text+"','"+text3.text+"')");
0
 

Author Comment

by:spoakes
ID: 17060723
This is working perfectly now - thanks!!

Quick follow-up question: what's the best way to close that popup window from flash?
0

Featured Post

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is primarily concerned with ActionScript 3 and generally specific to AVM2.  Most suggestions would apply to ActionScript 2 as well, and I've noted those tips that differ between AS2 and AS3. With the advent of ActionS…
Here are some practices and techniques that can be adopted into your Flash/Flex application development process. Note: Not all "performance tips" provide an immediately-recognizable benefit.   This article does not include timing validation data,…
The goal of the tutorial is to teach the user how to how to record live broadcast.
The goal of the tutorial is to teach the user how to select the video input device. Make sure you have an input device that in connected and work and recognized by Adobe Flash Media Live Encoder and select it in the “video input” menu.

803 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question