Solved

flash form data to javascript popup

Posted on 2006-07-06
9
252 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
 
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
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Recently, I was asked to recommend a tracking system to be implemented on a clients website. As the entire site was built on flash, my first thought was to suggest custom built tracking system. However, our company at that point of time didn't h…
The last time I worked with Flash and Socket connections was in AS1. A recent project required flash connecting to a Socket, and sending receiving information - we figured it would be easy enough - we all know about the socket policy documents and c…
In this tutorial viewers will learn how to create a basic motion tween animation in Flash Open a new document in Flash: Draw/import an image: Press CTRL + F8 to convert it into a graphic symbol: Select a frame (how long you want the tween to last): …
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.

746 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now