|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Hey I'm trying to create a flash form that contains some combo boxes. How do I pull the current data off the combo box and send it to php? Also, the default value of the combo box is blank, so how to I validate it when the user clicks "submit" to ensure he has selected an option.
Thanks. |
|
#2
|
|||
|
|||
|
Hi, found this which answers half of your question
Getting variables from a combo box into php The gist of it is: function getthevalue() { passthis = mycombobox.getSelectedItem(); loadVariablesNum ("myfile.php", "0", "POST"); } Now to check validate the user data you can be very specific i.e. function getthevalue() { passthis = mycombobox.getSelectedItem(); if(passthis == "news" || passthis =="home" || passthis == "fred") { loadVariablesNum ("myfile.php", "0", "POST"); } else if(passthis == "tom") { loadVariablesNum ("tomsfile.php", "0", "POST"); } else{ _root.messageBox.text = "please select an option"; } } If your not to fussed to check that closely then you can just use: function getthevalue() { passthis = mycombobox.getSelectedItem(); if(passthis != "") { loadVariablesNum ("myfile.php", "0", "POST"); } else{ _root.messageBox.text = "please select an option"; } } |
|
#3
|
|||
|
|||
|
Thanks for the advice. You have solved my problems. I send many thanks and Holiday Wishes your way!
|
|
#4
|
|||
|
|||
|
Which string do we have to put in the php file regarding the selected label in the combo box?
PHP file will look like this: <?php { $db = mysql_connect("localhost", "DB", "Password"); mysql_select_db("DB"); $sql = "INSERT INTO Table (field1,field2,field3) VALUES ('$??????','$var2','$var3')"; $result = mysql_query($sql); echo "Thank you! Information entered.\n"; } ?> The '$??????' should be the selected label of the combobox; I tried with '$passthis' and '$mycombobox' but it doesn't work. What is the good parameter? My Flash code for the submit button is : on (release) { if (this.var2 == '' || this.var2 == null || this.var3 == '' || this.var3 == null) { this.messok = 'Please make sure that ...'; } else { function getthevalue() { passthis = mycombobox.getSelectedItem(); loadVariablesNum ("http://url/myphp.php", 0, "POST");} messok = "Thank you for your interest. "; } } The Flash code for the combo box is: form = new Object(); form.change = function (evt){ trace(evt.target.selectedItem.label); } mycombobox.addEventListener("change", form); Thanks in advance. |
![]() |
| Viewing: Dev Shed Forums > Web Design > Flash Help > Flash MX Combo Box Component |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|