08-04-2003, 10:13 AM
|
#1
|
|
Registered User
Join Date: Jul 2003
Location: Illinois
Posts: 15
|
passing radio button variables/values
Hello,
I'm new to this game, so please forgive me if I stumble.
I've looked over all of the tutorials, and through all of the forums on this topic. I've found many answers, but they just don't work for me. I'm sure I'm doing something wrong, so I'm asking for assistance.
Here's the deal. I have a multi-frame form. Users can navigate back and forth through the sections of the form at will. It holds the values in each section of the form that the user inputs. This allows the user the option of being able to go back to a previous section of the form to change something if they want.
I have an "All Actions" layer that extends the entire length of all of the frames. The code in the "All Actions" layer is as follows:
ActionScript Code:
// set tab index for form fields
fName.tabIndex = 0;
mInit.tabIndex = 1;
lName.tabIndex = 2;
department.tabIndex = 3;
supFname.tabIndex = 4;
supLname.tabIndex = 5;
supEmail.tabIndex = 6;
// disable tab on certain buttons
homeButton.tabEnabled = false;
ckfreeButton.tabEnabled = false;
contUsButton.tabEnabled = false;
createPlanButton.tabEnabled = false;
// push button callback
function onClick(btn)
{
trace("onClick " + btn._name);
if ( btn == pg1next ) {
// continue button on page 1
getDataFromUIPg1(); // get the data out of ui components on page 1
gotoAndStop("pg2"); // go to pg 2
} else if ( btn == pg2prev ) {
// prev button on page 2
getDataFromUIPg2(); // get the data out of ui components on page 2
gotoAndStop("pg1"); // go to pg 1
} else if ( btn == pg2next ) {
// continue button on page 2
getDataFromUIPg2(); // get the data out of ui components on page 2
gotoAndStop("pg3"); // go to pg 3
} else if ( btn == pg3prev ) {
// prev button on page 3
getDataFromUIPg3(); // get the data out of ui components on page 3
gotoAndStop("pg2"); // go to pg 2
} else if ( btn == pg3next ) {
// continue button on page 3
getDataFromUIPg3(); // get the data out of ui components on page 3
gotoAndStop("pg4"); // go to pg 4
} else if ( btn == pg4prev ) {
// prev button on page 4
getDataFromUIPg4(); // get the data out of ui components on page 4
gotoAndStop("pg3"); // go to pg 3
} else if ( btn == pg4next ) {
// continue button on page 4
getDataFromUIPg4(); // get the data out of ui components on page 4
gotoAndStop("pg5"); // go to pg 5
} else if ( btn == pg5prev ) {
// prev button on page 5
getDataFromUIPg5(); // get the data out of ui components on page 5
gotoAndStop("pg4"); // go to pg 4
} else if ( btn == pg5next ) {
// continue button on page 5
getDataFromUIPg5(); // get the data out of ui components on page 5
gotoAndStop("pg6"); // go to pg 6
} else if ( btn == pg6prev ) {
// prev button on page 6
getDataFromUIPg6(); // get the data out of ui components on page 6
gotoAndStop("pg5"); // go to pg 5
} else if ( btn == pg6next ) {
// continue button on page 6
getDataFromUIPg6(); // get the data out of ui components on page 6
gotoAndStop("pg7"); // go to pg 7
} else if ( btn == pg7prev ) {
// prev button on page 7
getDataFromUIPg7(); // get the data out of ui components on page 7
gotoAndStop("pg6"); // go to pg 6
}
}
// get the data from the ui elements on page 1
function getDataFromUIPg1()
{
loginData.FnameField = fName.text;
loginData.MinitField = mInit.text;
loginData.LnameField = lName.text;
loginData.departmentField = department.text;
loginData.supFnameField = supFname.text;
loginData.supLnameField = supLname.text;
loginData.supEmailField = supEmail.text;
}
// get the data from the ui elements on page 2
function getDataFromUIPg2()
{
loginData.coreLead = compLeadership.getValue();
loginData.coreInit = compInitiative.getValue();
loginData.coreCommit = compCommit.getValue();
loginData.coreCommun = compCommun.getValue();
loginData.coreTeam = compTeam.getValue();
loginData.coreCustServ = compCustServ.getValue();
loginData.coreJobKnow = compJobKnow.getValue();
}
// get the data from the ui elements on page 3
function getDataFromUIPg3()
{
// do nothing
}
// get the data from the ui elements on page 4
function getDataFromUIPg4()
{
loginData.devGoalField = devGoal.text;
}
// get the data from the ui elements on page 5
function getDataFromUIPg5()
{
loginData.devActivityField = devActivity.text;
}
// get the data from the ui elements on page 6
function getDataFromUIPg6()
{
loginData.trainField = training.text;
}
// get the data from the ui elements on page 7
function getDataFromUIPg7()
{
loginData.whatQuarter = quarter.getValue();
}
// set the state of the ui elements on page 1 based
// upon the login data object
function updateUIFromDataPg1()
{
fName.text = loginData.FnameField;
mInit.text = loginData.MinitField;
lName.text = loginData.LnameField;
department.text = loginData.departmentField;
supFName.text = loginData.supFnameField;
supLName.text = loginData.supLnameField;
supEmail.text = loginData.supEmailField;
}
// set the state of the ui elements on page 2 based
// upon the login data object
function updateUIFromDataPg2()
{
compLeadership.setValue(loginData.coreLead);
compInitiative.setValue(loginData.coreInit);
compCommit.setValue(loginData.coreCommit);
compCommun.setValue(loginData.coreCommun);
compTeam.setValue(loginData.coreTeam);
compCustServ.setValue(loginData.coreCustServ);
compJobKnow.setValue(loginData.coreJobKnow);
}
// set the state of the ui elements on page 3 based
// upon the login data object
function updateUIFromDataPg3()
{
// no ui
}
// set the state of the ui elements on page 4 based
// upon the login data object
function updateUIFromDataPg4()
{
devGoal.text = loginData.devGoalField;
}
// set the state of the ui elements on page 5 based
// upon the login data object
function updateUIFromDataPg5()
{
devActivity.text = loginData.devActivityField;
}
// set the state of the ui elements on page 6 based
// upon the login data object
function updateUIFromDataPg6()
{
training.text = loginData.trainField;
}
// set the state of the ui elements on page 7 based
// upon the login data object
function updateUIFromDataPg7()
{
quarter.setValue(loginData.whatQuarter);
}
function initData()
{
// make sure we only call initData once
if ( inited )
return;
inited = true;
// set initial values
loginData = new Object();
loginData.FnameField ="";
loginData.MinitField ="";
loginData.LnameField ="";
loginData.departmentField ="";
loginData.supFnameField ="";
loginData.supLnameField ="";
loginData.supEmailField ="";
loginData.devGoalField ="";
loginData.devActivityField ="";
loginData.trainField ="";
}
I have a button that has the following code:
on (release) {
getURL("http://localhost/testCdt/createDevPlan.asp", 0, "POST");
}
In my .asp file I use a:
<%= Request.Form("fName") %>
for every variable. I use this .asp file to write this info to the database.
Here's the deal. The text fields works just fine. The radio buttons give me an [object Object] entry into the database.
 What am I doing wrong? Any help that you can give me will be greatly appreciated.
Thanks in advance.
|
|
|
08-05-2003, 10:32 AM
|
#2
|
|
done
Join Date: Jun 2001
Location: portland, or
Posts: 8,106
|
getValue() is a method of radiobuttongroups, your code is for radio button groups correct?
also, try reorganizing your code, so your variable values are set when the radio buttons a selected, via changehandlers for the radiobuttons.
__________________
tg
---
what the hell was i thinking?
|
|
|
08-05-2003, 11:44 AM
|
#3
|
|
Registered User
Join Date: Jul 2003
Location: Illinois
Posts: 15
|
Yes, the getValue() addresses the radiobuttongroups of:
compLeadership, compInitiative, etc.
About the changehandler:
Again, forgive me cause I'm new, but are you telling me to input a function name into the "Change Handler" radio button parameter, which I would call on my "all actions" layer? How would I do that? Would I have to set each variable by hand for the radio button group that it belongs too depending on which radio button is selected? Why couldn't I just grab the "data" of the radio button parameter and use that to pass to the database? If I could, how do I grab that?
I was assuming that if a radio button was selected in a group it would register that "data" value. I would then just pass that "data" value along?
I am sure I am missing something here, please stay with me and be patient, cause I have a hard head.
|
|
|
08-05-2003, 02:00 PM
|
#4
|
|
done
Join Date: Jun 2001
Location: portland, or
Posts: 8,106
|
don't know, i use radio buttons all the time, and use the getValue to grab info from the group with no problems.
i'm just throwing out options... my guess there is something else in your fla causing the problem.
start small run some tests see if it works outside your fla.
see if this works for you.
__________________
tg
---
what the hell was i thinking?
|
|
|
08-05-2003, 02:00 PM
|
#5
|
|
done
Join Date: Jun 2001
Location: portland, or
Posts: 8,106
|
if it will fit, why don't you post your fla.
__________________
tg
---
what the hell was i thinking?
|
|
|
08-05-2003, 03:26 PM
|
#6
|
|
Registered User
Join Date: Jul 2003
Location: Illinois
Posts: 15
|
Thanks for all your help!
Tried to load my flash file, but it was too big....
I'll play around with it until and see what I can get it to do.
|
|
|
08-06-2003, 09:28 AM
|
#7
|
|
Registered User
Join Date: Jul 2003
Location: Illinois
Posts: 15
|
Ok, here's the deal...
First, I tried to cut out all of the scenes and leave the form, and it still was too big to post the flash file.
So I'll try to explain it as best as I can.
I used the trace and realized that I was receiving all of my text variables, which I knew, and one of my radiobuttongroup variables, "quarter", which is on the same frame, but different layer, as my submit button. The other radio buttons are on a different layer, and on a different frame, but...
This baffled me because my "all actions" layer extends across all of the frames within my timeline, so it should be accessible at anytime. The text boxes are so why aren't the radiobuttongroups?
If you would look at the actionscript that I submitted for review, the form is seperated in sections, or pages. It holds the populated data in the forms so the user can go back and forth between the pages and make changes before they submit the form. The code above is in my "all actions" layer which extends through my whole timeline of pages, which should make it accessible from all parts of the movie.
So the question is.. why am I getting all of my text variables and one of my radio group variables, and not the other radio group variables?
|
|
|
08-06-2003, 09:32 AM
|
#8
|
|
Registered User
Join Date: Jul 2003
Location: Illinois
Posts: 15
|
oh, forgot to mention...
when I perform a trace on the variables...
the radio group buttons that I am having problems with show up as "undefined"...
the one radio group button shows what I populated in its "data" field, and the text input boxes gives the data that was input into the boxes...
Thanks.
|
|
|
08-06-2003, 11:00 AM
|
#9
|
|
done
Join Date: Jun 2001
Location: portland, or
Posts: 8,106
|
Quote:
Originally posted by acperez
the radio group buttons that I am having problems with show up as "undefined"...
|
recheck the spelling of all your radiobutton/radiobutton group instance names.
__________________
tg
---
what the hell was i thinking?
|
|
|
08-08-2003, 09:59 AM
|
#10
|
|
Registered User
Join Date: Jul 2003
Location: Illinois
Posts: 15
|
Got it working!!!!
Here was the problem...
I needed to, for some reason, on the onRelease function of my button, set the variables of the radio buttons from the "container" that I had them in, back to the radiobuttongroup variable name. It would not pass the "container" variable for some reason, nor the radiobutton group name unless I did this. What was even freakier was since one of the radio group buttons was on the same frame as the "submit" button, I had to get its value in order to pass it, even though its value should have been in the "all actions" layer which covered all of the frames. Here's what I added right after the onRelease in the code I provided previously:
ActionScript Code:
compLeadership = loginData.coreLead;
compInitiative = loginData.coreInit;
compCommit = loginData.coreCommit;
compCommun = loginData.coreCommun;
compTeam = loginData.coreTeam;
compCustServ = loginData.coreCustServ;
compJobKnow = loginData.coreJobKnow;
quarter = (quarter.getValue());
This works!! It passes the variables to the .asp page which writes the values to the database just fine.
I'm now trying to validate the form, and if something is missing I redirect the user to the section of the form that it is missing in. Guess what, I'm having a problem with the radiobuttons loosing their values!!!  The text input fields holds thier data just fine, of course.
Nothing comes easy...
|
|
|
| Thread Tools |
|
|
| Display Modes |
Rate This Thread |
Linear Mode
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT. The time now is 09:32 PM.
///
|
|