Skip to main content
October 18, 2010
Answered

How to retrieve data from combobox?

  • October 18, 2010
  • 2 replies
  • 1032 views

Hey guys!

I'm doing an order form, where the user can input his contact information and then choose a product in a dropdown menu.

Untill now, I just gave the dynamic text fields a variable and used this code:

on (release) {

     form.loadVariables("order.php", "POST");

}

But now that I added a combobox, it has no "varible field" - how do I send the selected parameter in the combobox to the php-file as well?


Thank you!!

This topic has been closed for replies.
Correct answer kglad

your combobox has a selectedItem property you can use:

var yourcomboboxselectedItem:String=cb.selectedItem.data;  // if you combobx has instance name cb and you want retrieve the data property

2 replies

kglad
Community Expert
Community Expert
November 14, 2010

try:


on (release) {

form.somevariable=cb.selectedItem.data    
form.loadVariables(order.php, POST);
}


November 16, 2010

Man, I still can't get it to work, allthough I did what you wrote.

Here's an illustration showing how I set it up:

http://www.emillyngbo.dk/flashproblem.jpg

Here's a link to my test page: www.emillyngbo.dk/email/email.swf

Also, this is my php-file, where you can see I use "somevariable" to try and target the Combobox:

$sendTo = "myemail@email.com"; $subject = "My Flash site reply";

$headers = "From: " . $_POST["firstName"] ." ". $_POST["lastname"] . "<" . $_POST["email"] .">\r\n"; $headers .= "Reply-To: " . $_POST["email"] . "\r\n";

$headers .= "Return-path: " . $_POST["email"];

$message = $_POST["message"] . $_POST["name"] . $_POST["somevariable"];

mail($sendTo, $subject, $message, $headers); ?>

kglad
Community Expert
Community Expert
November 16, 2010

is send a true button or a movieclip button?  does you combobox have instance name cb?

if send is a true button and cb is the instance name of your combobox use:

form.loadVariables("order.php","POST");

kglad
Community Expert
kgladCommunity ExpertCorrect answer
Community Expert
October 18, 2010

your combobox has a selectedItem property you can use:

var yourcomboboxselectedItem:String=cb.selectedItem.data;  // if you combobx has instance name cb and you want retrieve the data property

November 14, 2010

Thank you for your answer.

Sorry it took me this long to get back, but I still have a problem.

Where do I put that piece of code, for it to work, when the button is pressed?