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

Need Serious Help.

Status
Not open for further replies.

ebarratt

Programmer
Apr 10, 2002
53
US
Ok here's the problem i'm having. I'm using serverside asp code to generate a javascript object with to properties for
the object which are ID, and Description. Can anyone tell me why cboTeam.value = aryTeam[0].Id is undefined? I would really appreciate someone that knew what they were doing to help me out here. I use the ONLOAD event of the body tag to call trythis javascript function. The javascript array is populating values when i view the source code. Should I be passing in the object to the trythis function or something?


<SCRIPT LANGUAGE='JavaScript'>
<!--HIDE FROM OLDER BROWSERS

var aryTeam = new Array();
<% CALL subCboTeam() %>

function trythis(frmThis)
{
frmThis.cboTeam.options[0] = new Option(&quot;&quot;);
frmThis.cboTeam.options[0].value = aryTeam[0].ID;
frmThis.cboTeam.options[0].text = aryTeam[0].Description;
return;
}

//-->
</SCRIPT>

<%
SUB subCboTeam()
DIM x
strSQL = &quot;SELECT TNCODE, TNDESC FROM TBLTEAMNAMES ORDER BY TNDESC&quot;
SET rsTemp = dbConn.Execute(strSQL)
IF rsTemp.EOF = FALSE THEN
rsTemp.MoveFirst
x = 0
DO WHILE rsTemp.EOF = FALSE
Response.Write &quot;aryTeam[&quot; & x & &quot;] = '&quot; & rsTemp.Fields(&quot;TNCODE&quot;) & &quot;';&quot; & vbNewLine
Response.Write &quot;aryTeam[&quot; & x & &quot;].ID = '&quot; & rsTemp.Fields(&quot;TNCODE&quot;) & &quot;';&quot; & vbNewLine
Response.Write &quot;aryTeam[&quot; & x & &quot;].Description = '&quot; & rsTemp.Fields(&quot;TNDESC&quot;) & &quot;';&quot; & vbNewLine
rsTemp.MoveNext
x = x + 1
LOOP
END IF
END SUB
%> Errol Barratt
856-697-1593
New Jersey
 
you should write id not ID or Id or iD, this is probably why you are getting the undefined message
 
I found out why, cause you need to assign an array element to an object function. That enables you to use properties and methods in an array witht he dot delimiter. Thanks for your insight though. Errol Barratt
856-697-1593
New Jersey
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top