SitePoint Sponsor |
|
User Tag List
Results 1 to 4 of 4
-
Aug 30, 2010, 08:31 #1
- 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>
-
Aug 30, 2010, 08:56 #2
- 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
-
Aug 30, 2010, 09:14 #3
- 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:
<%@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
-
Aug 30, 2010, 18:58 #4
- 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