Click to See Complete Forum and Search --> : How to validate combo boxes?
mussicc
04-15-2007, 09:20 PM
Please help me out with this problem. Everything else has been working perfectly except when it comes to validating combo boxes.
This is part of the code:
if (meet_first.text == "" || meet_last.text == "" || meet_email.text == "" || meet_thetime.text == "" || meet_month.getselectedItem() == "" || meet_day.getselectedItem(0) == "" || meet_ampm.getselectedItem() == "" || meet_reason.text == "")
{
result_meet.gotoAndPlay("go");
result_meet.myresult.text = "Fields with (*) must be filled.";
}
Am I using the correct properties?
Any help would be very appreciated.
* mussicc
Stoke Laurie
04-16-2007, 05:37 PM
result_meet.gotoAndPlay("go");
result_meet.myresult.text = "Fields with (*) must be filled.";
mussicc
It looks like you have taken this from a Chris Seahorn load vars example, which is fine, as long as you realise that the gotoandplay function refers to a movie clip chris had on his stage called myresult I think. otherwise the code looks fine.
dniezby
04-16-2007, 09:15 PM
Please help me out with this problem. Everything else has been working perfectly except when it comes to validating combo boxes.
This is part of the code:
if (meet_first.text == "" || meet_last.text == "" || meet_email.text == "" || meet_thetime.text == "" || meet_month.getselectedItem() == "" || meet_day.getselectedItem(0) == "" || meet_ampm.getselectedItem() == "" || meet_reason.text == "")
{
result_meet.gotoAndPlay("go");
result_meet.myresult.text = "Fields with (*) must be filled.";
}
Am I using the correct properties?
Any help would be very appreciated.
* mussicc
Could you attach your fun file? I see where you're probably getting confused but I can't help if I can't see where your textboxes or variables lead.
Just to note though, you're trying to validate text boxes in your example not comboboxes.
Make sure to include dependencies with your fun file. I can help then.
Chris_Seahorn
04-16-2007, 10:42 PM
This example is a little more involved than you need but it's meant to give you ideas. Dissect what is useful and save the rest for down the road :)
http://flex.hobby-site.com/examples/musicc_combovalidate.html
mussicc
04-16-2007, 10:43 PM
Yes, indeed, I'm using Chris Seahorn's loadvars script. I have removed the text boxes to make it more simple and less confusing.
Your help is great appreciated!
* mussicc
mussicc
04-16-2007, 10:47 PM
Thanks, Chris - That's exacltly what I was looking for!
*mussicc
Chris_Seahorn
04-16-2007, 10:56 PM
Before I head back to the cave...I want to mention... (Wilbert has also mentioned this many times before as well)......
Always make sure to give the components at least two frames...the first one to create it and the scripting on the second (or any frame after the original frame it was placed in the timeline).
For example if I coded that whole thing on one frame I could validate the combobox (read it's chosen value) but could not send commands to it. This line which tells it to default to it's first item (which has no value on purpose :)):
meet_ampm.setSelected(0);
would fail on a one frame movie using a combo.
As long as the combo is already placed and I script it on a following frame (frame two in my example) it will accept the command to control it as well as read it :)
dniezby
04-17-2007, 02:22 AM
That is a lot to do for reading the choice of a simple checkbox. Here is what I do. You choose with method works best for your application.
On stage are two items.
my combobox and a dynamic textbox.
Name your textbox "choice1" or whatever you want.
Select properties of the combobox. Add your values. In the on Change box add this action script.
_root.choice1.text = getValue();
That's it.
Whatever the user selects will put the response in the textbox and you can now send the data using which ever method you choose.
When the form goes live you can hide the textbox behind your background image, off stage (_x = 2000; ) or just change the colors other attributes so it can't be seen.
See it in action (http://www.nsfilms.com/km/combo.swf)
Chris_Seahorn
04-17-2007, 02:48 AM
So...let's see now...his original....
if (meet_first.text == "" || meet_last.text == "" || meet_email.text == "" || meet_thetime.text == "" || meet_month.getselectedItem() == "" || meet_day.getselectedItem(0) == "" || meet_ampm.getselectedItem() == "" || meet_reason.text == "")
His expected new based on the assumption no dropdown has been clicked (because most likely his does not contain an empty item value but even if it did it's easily addressed)...
if (meet_first.text == "" || meet_last.text == "" || meet_email.text == "" || meet_thetime.text == "" || meet_month.getselectedItem() == "" || meet_day.getselectedItem(0) == "" || meet_ampm.getValue()==undefined || meet_reason.text == "")
At the very worst even if he does choose to use a default with no value all he needs is:
meet_ampm.getValue()==undefined || meet_ampm.getValue()=="" added
So your solution is to add another textfield to track what is already contained in the value (or lack thereof ) in the combo? That is sound advice or efficient?...OK...if you say so... :)
I'm also pretty sure that your concerns here:
That is a lot to do for reading the choice of a simple checkbox.
Were pointed out here:
This example is a little more involved than you need but it's meant to give you ideas. Dissect what is useful and save the rest for down the road
Thanks for adding an uneeded object to his movie though...that might also be something he wants to do down the road :)
dniezby
04-17-2007, 09:08 AM
Sigh....why do you get so pissed when someone offers another point of view? I sense much anger in you.
In my example the textbox is only there for testing. It can be removed when it goes live.
Maybe this example would be better explained. (http://nsfilms.com/km/combo/Combobox.html)
Chris_Seahorn
04-17-2007, 09:38 AM
Who said I'm pissed? I'm actually in a great mood. Another bad call D :)
flashkit.com
Copyright WebMediaBrands Inc., All Rights Reserved.