Pues tienes dos problemas. En primer lugar de su edificio una variable que sólo existe en función de la. Cambio. Debido a cuestiones de su ámbito de aplicación va a tener dificultades para acceder a él fuera de la función.
Para solucionar esto es necesario crear una variable fuera de la función y establezca su valor cuando el cambio en materia de incendios. Así:
// create holder varialbes
var selItem = "";
var selLabel = "";
myComboBoxListener = new Object();
myComboBoxListener.change = function(eventObj) {
var eventSource = eventObj.target;
var theSelectedItem = eventSource.selectedItem;
var theSelectedItemLabel = theSelectedItem.data;
// attach your vars to the holder vars
selItem = theSelectedItem;
selLabel = theSelectedLabel;
// trace the variables here to show that they've changed
trace("item = "+selItem+" and label= "+selLabel);
};
myComboBox.addEventListener("change", myComboBoxListener);
// If you trace the vars here they'll be blank because the event hasn't fired yet.
trace("item = "+selItem+" and label= "+selLabel);
- // create holder varialbes
- var selItem = "";
- var selLabel = "";
-
- myComboBoxListener = new Object();
- myComboBoxListener.change = function(eventObj) {
- var eventSource = eventObj.target;
- var theSelectedItem = eventSource.selectedItem;
- var theSelectedItemLabel = theSelectedItem.data;
- // attach your vars to the holder vars
- selItem = theSelectedItem;
- selLabel = theSelectedLabel;
-
- // trace the variables here to show that they've changed
- trace("item = "+selItem+" and label= "+selLabel);
- };
- myComboBox.addEventListener("change", myComboBoxListener);
-
- // If you trace the vars here they'll be blank because the event hasn't fired yet.
- trace("item = "+selItem+" and label= "+selLabel);
-
-
Ahora, dependiendo de lo que tiene que hacer con las variables en PHP que podría hacer que el derecho dentro de la convocatoria en función de su cambio, pero probablemente más fácil tener una función separada para manejar todo eso que llaman en el interior del oyente.
// create holder varialbes
var selItem = "";
var selLabel = "";
myComboBoxListener = new Object();
myComboBoxListener.change = function(eventObj) {
var eventSource = eventObj.target;
var theSelectedItem = eventSource.selectedItem;
var theSelectedItemLabel = theSelectedItem.data;
// attach your vars to the holder vars
selItem = theSelectedItem;
selLabel = theSelectedLabel;
// function to run
cbchanged();
};
myComboBox.addEventListener("change", myComboBoxListener);
// function to run on change
function cbchanged(){
trace("cb changed. new item = "+selItem+" and new label= "+selLabel);
}
- // create holder varialbes
- var selItem = "";
- var selLabel = "";
-
- myComboBoxListener = new Object();
- myComboBoxListener.change = function(eventObj) {
- var eventSource = eventObj.target;
- var theSelectedItem = eventSource.selectedItem;
- var theSelectedItemLabel = theSelectedItem.data;
- // attach your vars to the holder vars
- selItem = theSelectedItem;
- selLabel = theSelectedLabel;
-
- // function to run
- cbchanged();
-
- };
- myComboBox.addEventListener("change", myComboBoxListener);
-
- // function to run on change
- function cbchanged(){
- trace("cb changed. new item = "+selItem+" and new label= "+selLabel);
- }
-
Es obvio que hay un montón de maneras de simplificar ese código pero es bueno saber que hay de nuevo.
En segundo lugar hay un par de maneras de pasar los datos a php / javascript, etc Echa un vistazo a los dos
sendAndLoadVars y
ExternalInterface para encontrar el mejor para su configuración.
If at first you don't succeed F1... If that doesn't work try Google!
//// Designer, Developer & Teacher - Interactive, Motion and 3D \\\\
Portfolio at WhenImNotSleeping.com