[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

flash form data to javascript popup

Posted on 2006-07-06
9
Medium Priority
?
260 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
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 1400 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

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

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

This is intended to introduce all collision detection principles in flash, their strengths, weaknesses and workarounds. The main method for Collision Detection in flash is using hitTestObject. But unless you'll be pushing rectangular shapes without …
I have found that much of my time doing support ends up being a constant repetition of the same steps to different people.  Early on I stated using web pages with Frequently Asked Questions (FAQs) to alleviate most of the burden.  Sometimes this jus…
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): …
This Micro Tutorial will teach to how to utilize bit rate in Adobe Flash Media Live Encoder.
Suggested Courses
Course of the Month19 days, 12 hours left to enroll

872 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