Solved

flash form data to javascript popup

Posted on 2006-07-06
9
253 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

I come across a lot of question about how to access things in the document class from a movieclip, or accessing something from a movieclip in the document class. It took me a while to figure this out but once I did it makes life so much easier. …
I have been doing hardcore actionscripting for some time; and needless to say I have faced a lot of problems in just understanding others' code rather than understanding what the code executes. A programmer's life can become hell when there are a lo…
In this tutorial viewers will learn how to create a basic shape tween animation in Flash including shape hints for smooth animation Open a new document in Flash: Draw a shape: Select another frame (how long you want the tween to be): Right click and…
The goal of the tutorial is to teach the user how to select which audio input to use. Once you have an audio input plugged into the laptop or computer, you will go into the audio input settings and choose which audio input you want to use.

867 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

23 Experts available now in Live!

Get 1:1 Help Now