CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Oct 2004
    Posts
    23

    Java Script in ASP

    This may sound a bit odd, but I am trying to mix JavaScript onclick event into ASP.

    I have ASP code to make a list of links from a database, that code looks like this

    Code:
    Response.Write "<a href=""" & recordset("url") &""" title=""" & recordset("name") &""">" & recordset("name") & "</a>"
    Is it possible to have the same kind of system that uses this JavaScript

    Code:
    <a href="URL" 
    	   onclick="window.open(this.href); return false;"
    	   onkeypress="window.open(this.href); return false;" title="Name">Name</a><br>
    I can never get the " and ' bits right

  2. #2
    Join Date
    May 2002
    Posts
    10,943

    Re: Java Script in ASP

    I assume the bolded parts are where you want the ASP to take over. Try...

    Code:
    <a href="<% Response.Write URL %>" 
    	   onclick="window.open(this.href); return false;"
    	   onkeypress="window.open(this.href); return false;" title="<% Response.Write NAME %>"><% Response.Write NAME %></a><br>
    If the post was helpful...Rate it! Remember to use [code] or [php] tags.

  3. #3
    Join Date
    Oct 2004
    Posts
    23

    Re: Java Script in ASP

    Yes the bold parts are where the record set bits are in the other bit of code I posted.

    I will give the above a try.

  4. #4
    Join Date
    Oct 2004
    Posts
    23

    Re: Java Script in ASP

    Great, got it working, thanks

  5. #5
    Join Date
    May 2002
    Posts
    10,943

    Re: Java Script in ASP

    You're welcome. Glad to help.
    If the post was helpful...Rate it! Remember to use [code] or [php] tags.

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

Featured