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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Passing variable from ASP page to populate list box.

Status
Not open for further replies.

cawthor

Programmer
May 31, 2001
89
US
I don't understand what is wrong!! I'm simply trying to pass a value from an ASP page.

Running my ASP code produces the following string:

&desc0=NO LONGER VALID&EOF=true&

If I generate this string by simply typing:

<%
response.write "&desc0=NO LONGER VALID&EOF=true&"
%>

...then my list box populates with the 'desc0' value no problem. However, when I generate the output from a database value: Eg:
<%
fp_sQry = "SELECT * FROM MasterTable"
RS.Open fp_sQry, adoCon, 3, 1
desc = RS.Fields("Code_Description")
RS.Close
response.write "&desc0=" & desc & "&EOF=true&"
%>

...then my list box only contains 2 single or 1 double quotes (I can't tell which it is). I don't understand as my page produces EXACTLY then same output string.

I tried adding actionscript to check that all variables had loaded...see below:

Frame 1:
myVars = new LoadVars();
myVars.load("test.asp");

Frame 2:
if (myVars.EOF == "true") {
gotoAndPlay(4)
}

Frame 3:
if (myVars.EOF == "true") {
gotoAndPlay(4)
} else {
gotoAndPlay(2)
}

Frame 4:
list.addItem(myVars.desc0);

Anyone have any ideas? I'm out!!!
 
You can't split up the loadVars object like that. It has to be something like this.

Code:
myVars = new LoadVars();
myVars.onload = function(){
    if (myVars.EOF == "true"){
        gotoAndPlay(4);
        list.addItem(myVars.desc0);
    }else{
        gotoAndPlay(2);
    }
}
myVars.load("test.asp");

Hope it helps.

Wow JT that almost looked like you knew what you were doing!
 
Thanks for the response. I must be doing something wrong. The code you suggested doesn't populate any value to the list box. Where would I place this code? I put it in frame 1 in place of what I originally had there. Where do I put my list box? Also in frame 1? Sorry if this is really basic...I'm new to this and just trying to get my head around it!

Thanks.
 
This is killing me!! Forget the list box and everything...I'm just trying to get the data imported from my ASP page. I have a 1 frame movie with this code:

myVars = new LoadVars();
myVars.load("test.asp");
myVars.onLoad = function(success) {
if (success) {
trace(_root.myVars.desc0);
} else {
trace("not loaded");
}
};

In my ASP page, if it contains the following then my trace works fine:

<%
response.write "&desc0=test&"
%>

However...if I 'build' the string within ASP then my trace only shows a double quote character:

<%
var1 = "test"
response.write "&desc0=" & var1 & "&"
%>

I just don't get it...I have searched high and low for an explaination to no avail. It can't be that difficult!!!!

Thanks for ANY help!
 
you dont' need the _root. It should just be:

Code:
myVars = new LoadVars();
myVars.load("test.asp");
myVars.onLoad = function(success) {
    if (success) {
        trace([highlight]myVars.desc0[/highlight]);  
    } else {
        trace("not loaded");
    }
};

Also remove the last "&" off of your variable string.

Code:
<%
dim var1
var1 = "test"
response.write "&desc0=" & var1
%>

That should do it.

Hope it helps.

Wow JT that almost looked like you knew what you were doing!
 
Hi,
Is there a way to pass the name of a file to my movie,with either javascript or asp. Right now I have it hard coded with the name, how do I pass it the name of a file with a variable instead.

Thanks in advance

var quizItems=new Array();
var myData=new XML();
myData.ignoreWhite=true;
myData.onLoad=onQuizData;
myData.load("stop();
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top