Results 1 to 3 of 3

Thread: Accessing functions that reside on the server

  1. #1
    Guest

    Question

    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.


  2. #2
    Frenzied Member monte96's Avatar
    Join Date
    Sep 2000
    Location
    Somewhere in AZ
    Posts
    1,379
    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..

  3. #3
    Frenzied Member monte96's Avatar
    Join Date
    Sep 2000
    Location
    Somewhere in AZ
    Posts
    1,379
    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
  •  



Click Here to Expand Forum to Full Width