flash form data to javascript popup

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!!
spoakesAsked:
Who is Participating?
 
Aneesh ChopraConnect With a Mentor Commented:
no not like that....

if you have textfield than ti should be like this:

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

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

Rgds
Aneesh
0
 
spoakesAuthor Commented:
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
Cloud Class® Course: MCSA MCSE Windows Server 2012

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

 
Aneesh ChopraCommented:
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
 
Aneesh ChopraCommented:
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
 
spoakesAuthor Commented:
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
 
Aneesh ChopraCommented:
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
 
spoakesAuthor Commented:
Got it. OK, I think this is my last question:

This is the actionscript?

---------

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

---------
0
 
spoakesAuthor Commented:
This is working perfectly now - thanks!!

Quick follow-up question: what's the best way to close that popup window from flash?
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.