View previous topic :: View next topic |
Author |
Message |
project
Joined: 25 Jul 2005 Posts: 1
|
Posted: Mon Jul 25, 2005 4:26 am Post subject: ASP/Javascript Programming |
|
|
hey
this may be a basic problem, but i am quiet new to asp/javascript. so i seek some help on this.
i have declared a global array in javascript, say....
var gfarray = new Array()
then i populated the same with sql recordset using vbscript or watever is the default language of ASP. like this...
---declaration and opening of recordset etc....
<%
set rs=server.createobject("ADODB.Recordset")
rs.open "select count(*) from subject_master", objcon, 1,3
cnt = rs(0)
rs.close
redim ar1(cnt)
redim ar2(cnt)
rs.open "select * from subject_master"
i = 1
for i = 1 to cnt
'response.write (cnt)
ar2(i) = rs("subject_area")
rs.movenext
next
rs.close
rs.open "select * from guest_faculty", objcon, 1, 3
rs.movelast
gfno=rs(0)+1
response.write(ubound(ar2))
%>
then populated the combo like this...
<%
for j = 1 to cnt
%>
<option value="<%=ar2(j)%>"><%=ar2(j)%></option>
<%
next
%>
now to retrieve the values of that array i am calling the function...
function generateOptions(){
var opt='';
for (var i=0;i<ar2.length;i++)
{
opt+='<option value="'+ar2[i]+'">'+ar2[i]+'</option>\n';
}
}
this function's supposed to fill the combo..,
but it is giving no values...the array is vacant...
please help me on this...
thank you
tdd |
|
Back to top |
|
|
administrator Site Admin
Joined: 01 Oct 2004 Posts: 183
|
Posted: Mon Jul 25, 2005 8:48 am Post subject: |
|
|
The generateOptions function is a JavaScript client-side function, while your array ar2 is server side array. You cannot access server-side variables (in your case array) form your client-side script.
However you can write the values of the ar2 into a JavaScript client-side variable, which of course can be accessed client-side... _________________ Peter
ASP & ASP.NET Articles and Tutorials |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2002 phpBB Group
|