SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Member
    Join Date
    Aug 2010
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    onclick how to pass dynamic asp variable and use it in another div?

    Hello, I am trying to access a dynamic asp variable with onclick either in a javascript function where I can use it globally or set another div id with this dynamic variable.

    Any help is very much appreciated. Thank you!



    <script>
    function doSomething(article_id)
    }
    return article_id;

    }
    </script>


    <a href="#test" onClick="doSomething("<%=rsHeadline("article_id")%>")">try here...</a>


    <div id="test">
    <%articleid = request.querystring("article_id") %>
    <% Response.Write article_id %>
    The article id is article_id</div>

  2. #2
    SitePoint Guru
    Join Date
    Jun 2007
    Posts
    691
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    not sure exactly what you're trying to accomplish, but, in general, to access server-side code from the client-side code you must use something like jQuery/Ajax

  3. #3
    SitePoint Member
    Join Date
    Aug 2010
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ^thanks for your reply webber!

    I am trying to access the article_id (which changes when clicked) inside the div called test... I have pasted in my entire code, please take a look again:



    <&#37;@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
    <html>
    <head>
    <script type="text/javascript" src="jquery.js"></script>
    <script>
    function doSomething(article)
    {
    return article;

    }
    </script>
    </head>
    <body>
    <div id="home">
    <%
    strSQL = "SELECT * FROM Article"
    set rsHeadline = server.CreateObject("ADODB.Recordset")
    rsHeadline.Open strSQL, objConn, 1
    %>
    <table width="100%" border="0" cellspacing="0">
    <%iOrder = 1
    Do Until rsHeadline.EOF%>
    <tr>
    <td>
    <a href="#test" onClick="doSomething("<%=rsHeadline("article_id")%>")">try here...</a>
    </td>
    </tr>

    <%rsHeadline.MoveNext
    iOrder = iOrder + 1
    Loop
    rsHeadline.Close
    set rsHeadline = nothing%>
    </table>
    </div>
    <div id="test">
    <%articleid=request.querystring("article_id")%>
    <% Response.Write article_id %>
    The article id is article_id
    </div>

    </body>
    </html>



    any help is much appreciated

  4. #4
    SitePoint Guru
    Join Date
    Jun 2007
    Posts
    691
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You're listing some article_id's in a loop, via ASP.

    To have that article_id value appear somewhere else on the screen when clicked as a link is a javacript task.

    You should contact a javacript support group to assist in that question.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •