Asp+flash drop-down list (show picture)

Source: Internet
Author: User
Tags split
asp+| dropdown | Drop-down List | Last time I introduced the database and Flash connection mode. Here, I will not say more ...
There is also the code in ASP. I'm not going to say anything. Just stick it out ...
<!--#include file= "conn.asp"-->
<%
Dim rsbiclass,outbigclass,outbigclassid
Sql= "SELECT * from Bigclass"
Set Rsbigclass=server. CreateObject ("Adodb.recordset")
Rsbigclass.open sql,conn,1,1
Do as not rsbigclass.eof
Outbigclass=outbigclass&rsbigclass ("Bigclass") & "/"
Outbigclassid=outbigclassid&rsbigclass ("id") & "/"
Rsbigclass.movenext
Loop
Response.Write ("outbigclass=" &outBigClass& "&")
Response.Write ("outbigclassid=" &outbigclassid)
Rsbigclass.close
Set bigclass=nothing
Conn.close
Set conn=nothing
%>
Save As Readbigclass.asp <!--#include file= "conn.asp"-->
<%
Dim Bigid,outsmallclass
Bigid=request. Form ("Bigid")
Sql= "SELECT * from Smallclass where bigid=" &bigid
Set Rssmallclass=server. CreateObject ("Adodb.recordset")
Rssmallclass.open sql,conn,3,3
Do as not rssmallclass.eof
Outsmallclass=outsmallclass&rssmallclass ("Smallclass") & "/"
Outsmallclasspic=outsmallclasspic&rssmallclass ("Pic") & "/"
Rssmallclass.movenext
Loop
Response.Write ("outsmallclass=" &outSmallClass& "&")
Response.Write ("outsmallclassid=" &outsmallclasspic)

Rssmallclass.close
Set rssmallclass=nothing
Conn.close
Set conn=nothing
%>
Save As Readsmallclass.asp, I believe everyone can understand this ASP code. If you don't understand. After the frame, I'll note.
--------------------------------------------------------------------------------
Now go into the flash inside to program.
Look for a drop-down list from the component and pull two into the scene. Name it separately as MYBIGCMB,MYSMACMB
Write in the first frame:
System.usecodepage = true;
var Readbigl = new Loadvars ();//define a Loavars class pair image.
Readbigl.load ("readbigclass.asp");//Load Readbigclass.asp page.
Readbigl.onload = function (su) {
if (su) {
Load readbigclass.asp Successful
_root.gotoandplay (2);
}
};
The majority of the second frame is used in the last frame. Nothing more than to get the data out of the database and put the data into a well-defined array.
Second frame:
var Bigclassa = new Array ();
var Bigclassida = new Array ();
For (i=0 i<readbigl.outbigclass.length; i++) {
Bigclassa = ReadBigL.outBigClass.split ("/", I);
Bigclassida = ReadBigL.outBigClassID.split ("/", I);
}
For (j=0 j<bigclassa.length; j + +) {//This is to put a large class into the first Drop-down list.
Mybigcmb.additem ({label:bigclassa[j], data:bigclassida[j]})//This is to add data for the Drop-down list, and if it's not clear, find a component tutorial to learn:
}
Intiitem = mybigcmb.selecteditem.data;//This is the value that was first displayed for the first Drop-down list, if you don't add this. So, when you run that flash, the second Drop-down list will have no value.
Getsmallclass (Intiitem);
This getsmallclass () is a custom function. The function is to get the value of the small class corresponding to the selected large class from the database. Take the value out and assign the value to the second Drop-down list.
Change----------------------------------------for--------Large class
my = {};
My.change = function (CMB) {//This is the Change event for a large class that is the first Drop-down list.
BIGIDF = cmb.target.selecteditem.data;//Gets the data value of the selected option in the first Drop-down list.
Getsmallclass (BIGIDF);
Here again the custom function is called. This is when the big class changes, take out the corresponding small class value from the database, and then remove the value and then assign the value to the second Drop-down list.
};
--------get the value of a small class from the database-----------------
function Getsmallclass (BIGIDF) var smallclasssv = new Loadvars ();
var smallclasslv = new Loadvars ();
Smallclasssv.bigid = BIGIDF;
Note that the way to write variables here is Smallclasssv.bigid, if you do not add the previous SMALLCLASSSV, then the Bigid value will not be uploaded to the loaded ASP file
Smallclasssv.sendandload ("readsmallclass.asp", SMALLCLASSLV, "POST");
This sendandload method is used to load page pages. and return the results to the SMALLCLASSLV class.
Smallclasslv.onload = function (su) {
Note that the OnLoad event here is SMALLCLASSLV, not SMALLCLASSSV (when you first use this method, it is here that I am ^_^ long)
if (su) {
_global.smallclass = Smallclasslv.outsmallclass;
_global.smallclassid = Smallclasslv.outsmallclassid;
Setsmallclass ();
This calls another custom function that assigns a value to the second Drop-down list and puts the data received by SMALLCLASSLV into the second Drop-down list.
} else {
Aa.text = "Data connection unsuccessful";
}
};
}
----Put the value of the small class in the Drop-down list----------------------------------------
function Setsmallclass () {//This is the custom functions. Its function is to assign a value to a small class (the second Drop-down list)
If you can understand the above, then the following must not be explained ... Oh....
var smallclass = _global.smallclass;
var smallclassid = _global.smallclassid;
var Smallclassa = new Array ();
var Smallclassida = new Array ();
For (i=0 i<smallclass.length; i++) {
Smallclassa = Smallclass.split ("/", I);
Smallclassida = Smallclassid.split ("/", I);
}
Mysmacmb.removeall ();
Clears the original value in this Drop-down list.
For (j=0 j<smallclassa.length; j + +) {
Mysmacmb.additem ({label:smallclassa[j], data:smallclassida[j]});
}
Picname = mysmacmb.selecteditem.data;//This is the first value to get the second Drop-down list.
Loadpic (picname);//Call the function that loads the picture.
}
Change of---------Small class-------------------------------
Mys = {};
Mys.change = function (CMB) {
This is a small type of change event
Sid = Cmb.target.selecteditem.data;//Gets the selected data value of the small class when the selected value (that is, SelectedItem) of the small class changes.
Loadpic (SID);//Call Load the value of the picture, small class one changes, then the corresponding display of the picture is to change.
};
-------------load an external picture------------------------------
function Loadpic (picname) {//This is the functions that load the picture.
_root.createemptymovieclip ("PICMC", 0);//Create a blank movie clip.
_root.picmc._x = 200;
_root.picmc._y = 100;//Sets the location of the blank movie.
_root.picmc.loadmovie (picname)//Load picture, notice inside Picname is when call this function, come in (in fact is the picture name)
}
Mybigcmb.addeventlistener (' Change ', my);//Add a Change event for the Drop-down list.
Mysmacmb.addeventlistener ("Change", Mys);
Stop ();
Ok,have a try!

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.