OBCT
asked on
Dynamically loading data into the drop down box
I have a UI componant (combo box) and I want to be able to load the list from a text file.
Is this possible? If so, how?
The other thing I need is to be able to send the selection from the combo box into a mysql database. I have set up a php page that sends the data from my text boxes to the database, so really all I need is to know how to send it to php.
I hope this makes sense, if not I'll try and explain better. Just let me know.
Cheers
-OBCT
Is this possible? If so, how?
The other thing I need is to be able to send the selection from the combo box into a mysql database. I have set up a php page that sends the data from my text boxes to the database, so really all I need is to know how to send it to php.
I hope this makes sense, if not I'll try and explain better. Just let me know.
Cheers
-OBCT
ASKER
Ok I've done that and its working fine.
I just have to more questions....
1) How can I adjust the width of the combo box?
2) I was intending on using LoadVars to send the data to my php page seeing the rest of my data is sent that way, but....
how to I get flash to get the variable the user has selected? e.g. a text box uses newVars.txt_1 = txt_1.text so what would/should I use for the combo box?
Cheers
-OBCT
I just have to more questions....
1) How can I adjust the width of the combo box?
2) I was intending on using LoadVars to send the data to my php page seeing the rest of my data is sent that way, but....
how to I get flash to get the variable the user has selected? e.g. a text box uses newVars.txt_1 = txt_1.text so what would/should I use for the combo box?
Cheers
-OBCT
your combo box will automatically adjust to the max item size... so you don't have to worry about that...
you can use loadvars if you want...
you would just send that information in the changeData function above.... like this:
function changeData(_cb)
{
myData = new LoadVars();
myData.yourVariable = _cb.getSelectedItem().data ;
myData.sendAndLoad("/yourp age.php", myData, "POST");
myData.onLoad = function(success){
if(success){
trace("successful transaction");
} else {
trace("an error occured in the transaction");
}
};
}
I believe, that is all you need... then you would collect the "yourVariable" using the method posted above by Negatyve....
hope that helps to clarify...
rp
you can use loadvars if you want...
you would just send that information in the changeData function above.... like this:
function changeData(_cb)
{
myData = new LoadVars();
myData.yourVariable = _cb.getSelectedItem().data
myData.sendAndLoad("/yourp
myData.onLoad = function(success){
if(success){
trace("successful transaction");
} else {
trace("an error occured in the transaction");
}
};
}
I believe, that is all you need... then you would collect the "yourVariable" using the method posted above by Negatyve....
hope that helps to clarify...
rp
ASKER
I tried adding the loadvars in my on release function, but now I'm having three problems.
1) The username and email are not being submited to my db anymore
2) The combo box didn't adjust its width automatically
3) In the database, in the column that contains my variable from the combo box, it says undefiend.
What did I do wrong??
1) The username and email are not being submited to my db anymore
2) The combo box didn't adjust its width automatically
3) In the database, in the column that contains my variable from the combo box, it says undefiend.
What did I do wrong??
ASKER
Sorry about those errors, they were my own little errors which I have fixed up now.
However, in my database I am still getting "undefiend" in the column that is meant to hold the value from my text box.
However, in my database I am still getting "undefiend" in the column that is meant to hold the value from my text box.
it should be:
$_POST['textfield_associat ed_variabl e']
$_POST['textfield_associat
ASKER
This is the code I am using, and it wont send anything into my database. The way I had it working before was using loadVariablesNum with the GET method...
any suggestions?
combo_cb.setEnabled(false) ;
data_xml = new XML();
data_xml.ignoreWhite = true;
data_xml.path = this;
data_xml.onLoad = function(ok)
{
this.path.combo_cb.setEnab led(true);
if(ok){
var nodes = this.firstChild.childNodes ;
for(var i = 0; i < nodes.length; i++){
this.path.combo_cb.addItem (nodes[i]. attributes .label, nodes[i].attributes.data);
}
this.path.combo_cb.setChan geHandler( "changeDat a");
this.path.changeData(combo _cb);
} else {
this.path.combo_cb.addItem ("no data found");
this.path.combo_cb.setEnab led(false) ;
}
};
function changeData(_cb)
{
this.newUser = _cb.getSelectedItem().data ;
}
data_xml.load("http://www.dfgsgsdfgsdfg.com/xml/combodata.xml");
submitBTN.onRelease = function() {
if (!username.length) {
status = "Please enter a username"
} else {
if (!email.length or email.indexOf("@") == -1 or email.indexOf(".") == -1 or email.indexOf("com") == -1) {
status = "Please enter a valid email"
} else {
if (email.length < 7) {
status = "Please enter a valid email"
} else {
status = "Loading...Please wait..."
var newUser = new LoadVars()
newUser.username = _root.username
newUser.email = _root.email
newUser.timeZone = _root._cb.getSelectedItem( ).data
newUser.load("http://www.dfgsfgsdfg.com/scripts/register.php", 0, "POST")
newUser.onLoad = function(success) {
if (success) {
status = "Complete"
} else {
status = "Error"
}
}
}
}
}
}
any suggestions?
combo_cb.setEnabled(false)
data_xml = new XML();
data_xml.ignoreWhite = true;
data_xml.path = this;
data_xml.onLoad = function(ok)
{
this.path.combo_cb.setEnab
if(ok){
var nodes = this.firstChild.childNodes
for(var i = 0; i < nodes.length; i++){
this.path.combo_cb.addItem
}
this.path.combo_cb.setChan
this.path.changeData(combo
} else {
this.path.combo_cb.addItem
this.path.combo_cb.setEnab
}
};
function changeData(_cb)
{
this.newUser = _cb.getSelectedItem().data
}
data_xml.load("http://www.dfgsgsdfgsdfg.com/xml/combodata.xml");
submitBTN.onRelease = function() {
if (!username.length) {
status = "Please enter a username"
} else {
if (!email.length or email.indexOf("@") == -1 or email.indexOf(".") == -1 or email.indexOf("com") == -1) {
status = "Please enter a valid email"
} else {
if (email.length < 7) {
status = "Please enter a valid email"
} else {
status = "Loading...Please wait..."
var newUser = new LoadVars()
newUser.username = _root.username
newUser.email = _root.email
newUser.timeZone = _root._cb.getSelectedItem(
newUser.load("http://www.dfgsfgsdfg.com/scripts/register.php", 0, "POST")
newUser.onLoad = function(success) {
if (success) {
status = "Complete"
} else {
status = "Error"
}
}
}
}
}
}
ASKER
Can someone please help!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I tried that, used $HTTP_POST_VARS on my php script and it didn't add anything into the database.
ASKER
I know there isn't anything wrong with my php page because when I try something like this:
http://www.sdlfhs.com/scripts/register.php?username=Blah&email=i_live@themoon.com
it enters it into the db.
http://www.sdlfhs.com/scripts/register.php?username=Blah&email=i_live@themoon.com
it enters it into the db.
ASKER
LOL sorry my bad. I forgot to save my php script after I changed everything to HTTP_POST_VARS.
Thanks for all your help, you really are an expert!
Cheers!
-OBCT
Thanks for all your help, you really are an expert!
Cheers!
-OBCT
yeah!! :)
cheers
cheers
<?xml version="1.0" encoding="UTF-8"?>
<combodata>
<item label="First Label" data="first" />
<item label="Second Label" data="second" />
<item label="Third Label" data="third" />
<item label="Fourth Label" data="fourth" />
<item label="Fifth Label" data="fifth" />
<item label="Sixth Label" data="sixth" />
</combodata>
then, in your movie, call your combobox, for example, "combo_cb", and drop this code on the same frame:
combo_cb.setEnabled(false)
data_xml = new XML();
data_xml.ignoreWhite = true;
data_xml.path = this;
data_xml.onLoad = function(ok)
{
this.path.combo_cb.setEnab
if(ok){
var nodes = this.firstChild.childNodes
for(var i = 0; i < nodes.length; i++){
this.path.combo_cb.addItem
}
this.path.combo_cb.setChan
this.path.changeData(combo
} else {
this.path.combo_cb.addItem
this.path.combo_cb.setEnab
}
};
function changeData(_cb)
{
this.yourVariable = _cb.getSelectedItem().data
}
data_xml.load("combodata.x
with this code, when you change the selected item, the "yourVariable" variable is created in the same timeline where the combo lies, holding the selected item data.
If you want to create it in a loadVars instance, change the code to:
data_var = new LoadVars();
combo_cb.setEnabled(false)
data_xml = new XML();
data_xml.ignoreWhite = true;
data_xml.path = this;
data_xml.onLoad = function(ok)
{
this.path.combo_cb.setEnab
if(ok){
var nodes = this.firstChild.childNodes
for(var i = 0; i < nodes.length; i++){
this.path.combo_cb.addItem
}
this.path.combo_cb.setChan
this.path.changeData(combo
} else {
this.path.combo_cb.addItem
this.path.combo_cb.setEnab
}
};
function changeData(_cb)
{
data_var.yourVariable = _cb.getSelectedItem().data
}
data_xml.load("combodata.x
Now, when you send you data to php (you know how, if you send data from textfields), you get that variable with:
$_POST['yourVariable']