Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

HELP with Flash MX Combo Box Component 1

Status
Not open for further replies.

aspnewbee

MIS
Jul 11, 2004
34
US
Hi I'm trying to insert some data into my DB from two Combo Boxes in Flash. I'm not quite sure how to go about it. I have one combo box listed in the actionscript below. Can anyone help me please....
Thank you all in advance.

ACTIONSCRIPT:
on (release) {
function getthevalue() {
passthis = major.getSelectedItem();
if(passthis != "")
{
loadVariablesNum (" "0", "POST");
}
else{
_root.messageBox.text = "please select an option";
}
}
nextFrame();
}

ASP CODE:

<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<%
strMajor = Request.Form("major")
strCollege = Request.Form("college")
'Response.Write(strMajor) & "<br>"
'Response.Write(strCollege) & "<br>"
MyPath=Server.MapPath("uginfo.mdb")
Set Conn = Server.CreateObject("ADODB.Connection")
conn.Open "Driver={Microsoft Access Driver (*.mdb)};" & _
"DBQ=" & MyPath
SQL = "INSERT INTO acad_choices (major, college) VALUES('"&strMajor&"', '"&strCollege&"')"
'Response.Write(SQL)
conn.Execute(SQL)
%>
 
In the properties for the ComboBox Component add a function Name..."getTheValue" in the ChangeHandler value (single click on the component and view the properties panel). Remove the on(release) action.

Then try this in your function:

Code:
function getTheValue(component){
	passThis = component.getValue();
	
	if (passThis != "") {
		loadMovieNum("[URL unfurl="true"]http://localhost/test/adacform.asp",0,"POST");[/URL]
	}else{
		_root.messageBox.text = "Please Select an Option";
	}
	_root.nextFrame();
}

Hope it helps!

Wow JT that almost looked like you knew what you were doing!
 
Hi pixl8r... thank you for the suggestion. I tried it but it still doesn't insert any record to the DB from the combo box. I don't know if my asp file has the problems... In my flash movie I created a submit button... thats why I had the on release{ .... }. I had the action set to that button. Now after I added this funtion you suggested the functionality of the submit button is lost... :( Could you help me out please... I just started using actionscript so... I need some extra explaination may be... thanks for your patience.

 
Well why didn't you say it was in a form? ;-)

Replace the change handler function with this:

Code:
function getTheValue(component){
    _root.passThis = component.getValue();
}
Make sure this function is the "change handler" in the properties for the combo box.

on the "submit" button:
Code:
on(release){
   major = _root.passThis;
   if (major != ""){
      loadVariables("[URL unfurl="true"]http://localhost/test/adacform.asp,"POST");[/URL]
   }else{
      trace("You must select a major");
   }
}

I think that will do it for you. Let me know if you need additional assistance. Glad to help if I can.

Wow JT that almost looked like you knew what you were doing!
 
Hi Pixl8r... I tried what you suggested and didn't seem to work... Please let me know if you want me to upload my .fla file so that you can take a look at it. Sorry to bother you. Thank you for all the help.

 
Yes please post a link to the .fla so I can have a look.
 
Ok you actually had multiple issues.

First issue: Your combo boxes had label values but there was no data attached to the label. I have filled in the first 4 of each combo as an example (look at combo box properties). This is a problem because there was no "data" to pass to your ASP page.

Second Problem:
The "Change Handler" property for both comboboxes was empty. That means that nothing happens when someone changes one. I created a change function for each combo box (similar to above) in the first frame of the main timeline and assigned it to a combo.

Look at the action on your submit button. You will see that it uses the loadVars() action instead of getURL or LoadVariables. loadVars is a little more robust and can be used for send, load, or send and load. What you were doing was not wrong per say... I just believe this will work better for you.

Change the loadVars.send address back to your ASP page.

By the way... I like what you've done here. You should really consider animating the owl in Flash. It would save you even more in file size. Just a thought.

Check it out and let me know if you have any questions!


Hope it helps.

Wow JT that almost looked like you knew what you were doing!
 
Thanks a million Pixl8r... I'm really greatful for all the help. It works great... I just have one small problem... when I hit the submit button... it still opens a new browser for the asp file... even after I changed the code to "0" from "_blank". Am I missing something here? Sorry for troubling you for small things like this... but I tried to figure out but couldn't find it. Thank you for the suggestions too... I'll surely make the animations to flash... and I'm so glad you like what I did.
This is how my actionscript is now:

mySendVars.send(" "0", "POST");
 
loadVars.send will not accept a level as a place to send variables. Where you inserted the "0" is a window variable. (so it must be "_blank","_parent","windowName", etc...) "0" won't do anything but open a new window (named "0").

What is it exactly you are trying to do with the information when you send it to the asp page?

Wow JT that almost looked like you knew what you were doing!
 
The information that I'm sending is going to a DB. So when I clcik the SUBMIT button I just want the asp page to load in the background and send the data to the DB. On the flash side I just want the flash page to go to the nextframe(). This is working fine in my other pages but this one. Any suggestions?

Thank you again.

 
OK then eliminate the target parameter. That will discard the server reponse.

Code:
mySendVars.send("[URL unfurl="true"]http://localhost/test/acadform.asp","POST");[/URL]

Let me know if that does the trick.



Wow JT that almost looked like you knew what you were doing!
 
Hi Pixl8r... I tried that... and it still opens a new window... seems very wierd... this is how the code looks now..

Code:
on (press) {
	//define a new loadVars object
	mySendVars = new LoadVars();
	//Insert values from combo box functions (or defaults)
	mySendVars.major = _root.strMajor;
	mySendVars.college = _root.strCollege;
	//send the variables to the asp page (replace with yours)
	mySendVars.send("[URL unfurl="true"]http://localhost/karl/acadform.asp",[/URL] "POST");
	nextframe()
}

Thanks for all your help and patience.

A.
 
Well to get the loadVars object to maintain state (not open a new window) you have to use the sendAndLoad method. That is complicated to implement in that it always seems to have a lot of troubleshooting that goes with it.

It is working for me going back to the loadVariables action.

Code:
on(press){
loadVariables("[URL unfurl="true"]http://localhost/karl/acadform.asp","_root","POST");[/URL]
}

To verify that it was working I added an empty dynamic text box to the main timeline with the var property of "_root.reply".

Following is my ASP:

Code:
<%
mystring = request.form("strMajor")
response.write "&reply=I received "&mystring
%>

After clicking submit the text of the reply message from the ASP page displays in the text box in the flash movie (without opening a new window). Give it a shot and let me know if that does it.

Wow JT that almost looked like you knew what you were doing!
 
Awesome... it works great... thanks a million Pixl8r. You've been a great help... it writes well to the DB too.. and the asp page doesn't open in a new page anymore.... thanks again.

A.
 
Great! Glad it helped.

Wow JT that almost looked like you knew what you were doing!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top