Ok, I'm officially a moron. I can't figure out how to assign a variable to a combo box...
It's probably a brain fart more than anything.
Printable View
Ok, I'm officially a moron. I can't figure out how to assign a variable to a combo box...
It's probably a brain fart more than anything.
Not sure what you mean. You want to populate the combobox with variables? Have items that are clicked in it define a variable? Or something other?
I'm officially a moron who can't read ;)
Let me put it this way.
I have a combobox with two items in it.
Male
Female
I want to assign the variable "gender" to the combobox. So that when the form is sent it sends the choice.
Gotcha. In Frame 2, in the onChange handler, you can do anything with the value you want where I commented it.
Why are there two boxes in your example?
Nevermind, I think I figured it out.
The two boxes are because you're assigning the variable to the Text box right?
Could I simply do this?
code:
// Male = 1
// Female = 2
gendervar= combobox1.getValue();
if (gendervar == 1){
gender = "Male";
} if (gendervar == 2){
gender = "Female";
}else{
gender = "";
}
No....that script will fail.
I think a combobox is not what you should use for what you are doing. You should use two checkboxes. One for male, one for female. When checked have it set that variable name (the same variable name you are using in your POST for gender) to "Male" or "Female".
Your example above, even if it were formatted right, would need to be part of an (onEnterFrame) routine that constantly checks the value of that one field....which is overkill for a form that most likely has more than one variable being sent out.
If this is confusing I will have to code an example.
EDIT: I see bret posted something for you in another thread so you should be good right?
Worst case scenario...if you can't figure out how to post variables....I have a download at my place that although it is a login form, will show you how to use loadVars.....POST only the fields you want...and how to get a result using sendAndLoad (Almost all forms return a result to notify the user of successful submission).
LOL, it wasn't even formatted correctly?
I'm going to make you something. I can't test it because I don't enable the mail server on my server (hate the stuff) but the front end will be easy to tie to your backend.
Maybe it should be noted that I use Jack's Formmail.php to process any email forms.
Looks like a good mail form processor. I would modify the error message to a variable format that way your flash form will recieve that message and you can act accourdingly.
Rework this part
Code:function print_error($reason,$type = 0) {
build_body($title, $bgcolor, $text_color, $link_color, $vlink_color, $alink_color, $style_sheet);
// for missing required data
if ($type == "missing") {
if ($missing_field_redirect) {
header("Location: $missing_field_redirect?error=$reason");
exit;
} else {
?>
The form was not submitted for the following reasons:<p>
<ul><?
echo $reason."\n";
?></ul>
Please use your browser's back button to return to the form and try again.<?
}
} else { // every other error
?>
The form was not submitted because of the following reasons:<p>
<?
}
echo "<br><br>\n";
echo "<small>This form is powered by <a href=\"http://www.dtheatre.com/scripts/\">Jack's Formmail.php ".VERSION."</a></small>\n\n";
exit;
}
Yeah, the script has been EXTREMELY reliable and so far, secure. I've made some changes to allow me to test things without uploading to the server other than that it's got some pretty cool features.
I don't use the missing_field_redirect that often. I figure, if I don't need the field, might as well just leave it out of the form.
I'll try the changes you've noted and see what they do. I'm pretty curious now.
OK....
Try this:
http://sandbox.blogdns.com/loadvars_mailform.swf
Try it. It also traps empty fields. I have it write the variables to a text file also so you can see it indeed gets all of them. You can see the variables written here:
http://sandbox.blogdns.com/mailform.txt
Whenever I make anything that posts to php I test using a text file. This lets you confirm the variables are being sent if they are not being sent to something obvious(like a database). It's a good habit to get into and with mail forms it definitely helps.
I'm not a big fan of wasting my time so if you already have a solution I'll just make this one of my downloads.
I don't like conflicting with a mod when they are posting a solution. I'll add this to my downloads for all platforms in case users want it.
To many cooks making this stew. Peace.
cool, I'll check out the downloads.
Is this the same answer to the "change the text variables to instances"?
Yeah...no more loadvariables and variable names for me.
This is loadVars with instance names.
Well, good. Then I look forward to the download and learn how you did this.
I see, the write to the text file was just for the example. In my form, I'll actually have it send the form data to the formmail.php right?Quote:
Try it. It also traps empty fields. I have it write the variables to a text file also so you can see it indeed gets all of them. You can see the variables written here:
Yeah...that coding is there it just doesn't send me any mail because the "mail" command is disabled on my server. The coding is there...that section you will remove in the php (and save it so you can always do that to test).
I would attach the file here but I almost got banned from Flashkit last year and one of my resolutions is to not trap my hard work as an attachment to a forum I may end up banned from. This year I worry about me first and the user second.
Huh, interesting.
Alright, just let us know when the download is available. Thanks for the help.
Don't run off cause of me... :) Mod just means I have to spank ya if you get out of line, it doesn't mean I;m a KM expert (I'm not)Quote:
Originally Posted by Chris_Seahorn
Not at all. Just didn't want to confuse any more than I have.
File is posted. I'm in kiosk mode for a couple of hours to run some tests but the satellites should allow users in fine.
Chris,
I put this code into the frame with my combobox but the combobox is empty when it loads.
code:
var gender = gender.text;
items = new Array();
items.push({label:'Choose Male',value:'Male'});
items.push({label:'Choose Female',value:'Female'});
combo.setItems(items,false,new TextFormat('Arial',12));
combo.onChange = function(v){
_root.gender.text=this.getValue();
//right here you can do anything with the value instead of above
};
//now when you submit your form...the value of gender.text will be the "gender" variable
stop();
Sorry man. I guess we have to give her a few frames to breath...
http://sandbox.blogdns.com/fk/dniezby_fk.swf
Ok, I must be doing something wrong...I can't for the life of me get it to work. I've tried and tried but it doesn't populate my combo box.
Here is the link to the fun file (+ the dependent files)
http://www.nsfilms.com/km/dniezby_webform.zip
If you have time, can you look at it? If you don't, don't sweat it...I'm sure I'll finally figure it out. That's part of the reason I love doing this stuff...Figuring out why programs don't work.
Since the timeline is short, I placed the combobox onstage at frame 1 and made it invisible so it can receive the array. When it gets called in frame 5 we make it visible and on frame 6 invisible again for when they advance past frame 5.
You will have to set the combo colors again. Sorry...I needed to place a new one.
Are comboboxes always this much of a pain?
I mean, I see a lot of people use them...
I'll download it now and check it out. See what the heck I was doing wrong.
Thanks a lot for the lessons.
:)
just had a look at it...That's IT !?
That's ALL I was doing wrong?
Man, that is frustrating. I was up researching the code all night and kept finding that I was pretty much on the money...I still don't understand why it didn't work the other way but...what the heck...it works now...
Thanks a million.
So, I'm guessing I should use this technique everytime I use a combobox?
BTW, any idea why it doesn't seem to work if I use the + button to add the combobox items?...Or can I? Hmm...
You should just enter them in the GUI. I usually code it that way out of habit because I usually populate them from php data and I like to use the scripted styling. The styling demos in the examples folders all build them this way too. It's just a preference.