|
-
Oct 3rd, 2000, 04:17 PM
#1
Hi there..... I'm trying to create a table and assign each one of its cells an id on the fly with my asp page. I have created a database that holds a set of generic ids to be used. Here's what my codes look like, maybe you'll understand better:
<%
set RS=server.createobject("adodb.recordset")
sql = "SLECT GenericIDs FROM IDs"
RS.open sql, "TaskManager", adOpenStatic, adLockPessimistic
RS.movefirst
Generated = RS("GenericIDs")
response.write "<table name=mytable border=2 cellspacing=1 width=500>"
response.write"<tr>"
FOR i = 0 to 8
response.write "<td id="&Generated&" onmousedown=AssignColor(Generated) width=30</td>"
RS.movenext
Generated = RS("GenericIDs")
NEXT
response.write "</tr></table>"
SUB AssignColor(id)
received = id
response.write "<script language=vbscript>mytable.cells.item(received).style.backgroundcolor=green </script>"
END SUB
%>
At this point it looks like the function AssignColor cannot be executed properly. The table is displayed but when I click on any cell I get a 'Error on page' response at the bottom left of my browser. I'd be extremely grateful if I could get some help on this one. Thanks in advance.
-
Oct 3rd, 2000, 07:42 PM
#2
Frenzied Member
I'll have a look at a way to do this..
your mixing up the server side code with your client side code. You can't call a sub that's on the server side from client side code (cuz it doesn't exist on the page) and response.write is not available in client side code at all.
oOOo--oOOo
__ /\/\onte96
oOOo--oOOo
Senior Programmer/Analyst
MCP
[email protected]
[email protected]
Your results may vary.. some restrictions may apply.. pricing and participation may vary.. not available in all states.. professional driver closed course..quantities limited..
-
Oct 4th, 2000, 10:21 AM
#3
Frenzied Member
Try this...
Code:
<HTML>
<BODY>
<%
Dim strSQL
Dim Generated
set RS=server.createobject("ADODB.Recordset")
strSQL = "SELECT GenericIDs FROM IDs"
RS.Open strSQL, "TaskManager", adOpenStatic, adLockPessimistic
Generated = RS.Fields("GenericIDs")
response.write "<table name=mytable border=2 cellspacing=1 width=500>"
response.write"<tr>"
Do until rs.EOF
response.write "<td id=" & Generated & " onmousedown=AssignColor(" & Generated & ") width=30></td>"
RS.movenext
Generated = RS.Fields("GenericIDs")
Loop
Response.write "</tr></table>"
%>
<SCRIPT Language="VBScript">
Sub AssignColor(id)
mytable.cells.item(id).style.bgcolor=green
End Sub
</SCRIPT>
</BODY>
</HTML>
<%
rs.close
Set rs = Nothing
'You didn't mention a connection object but you'll want to close and release it as well..
oOOo--oOOo
__ /\/\onte96
oOOo--oOOo
Senior Programmer/Analyst
MCP
[email protected]
[email protected]
Your results may vary.. some restrictions may apply.. pricing and participation may vary.. not available in all states.. professional driver closed course..quantities limited..
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|