Wrox Home  
Search P2P Archive for: Go

  Return to Index  

javascript thread: Getting data from a database and using JavaScript to populate a listbox


Message #1 by "Cool Cat" <coolcatology@h...> on Thu, 28 Mar 2002 18:54:01 -0800
I have a visual basic app that I'm using with a GetList method to return a 
two-dimensional array from the Access database.  It will return a skillID 
and and skillName.

I can't figure out how to populate a listbox on an ASP page using 
JavaScript.  This doesn't work:

<SELECT>
<%
// Create a skill object and get the list of skills
var icounter
var objSkill = Server.CreateObject("BO.cSkill");
var arrSkills = new Array();
arrSkills = objSkill.GetList();

var icounter = 0;
// Loop through the skills and print them into the listbox
Response.Write(arrSkills[0][0]);
	for (icounter=0; icounter < arrSkills[0].length; icounter++)
	{
		Response.Write("<OPTION>");
		Response.Write(arrSkills[0][icounter]);
		Response.Write("</OPTION>");
	}
objSkill = null
%>
</SELECT>

Maybe I just don't have a clue how to use arrays in JavaScript.
I managed to use VBScript (below)and populate the listbox just fine, but I 
need to figure out how to do it using JavaScript:

<SELECT>
<%
set objSkill = Server.CreateObject("BO.cSkill")
arrSkills = objSkill.getList

For icounter=0 to UBound(arrSkills, 2)
	Response.Write("<OPTION>")
	Response.Write(arrSkills(1, icounter))
	Response.Write("</OPTION>")
Next

set objSkill = nothing
%>
</SELECT>

_________________________________________________________________
Join the world?s largest e-mail service with MSN Hotmail. 
http://www.hotmail.com


  Return to Index