Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 9 of 9
  1. #1
    New to the CF scene
    Join Date
    Feb 2005
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Asp - OnClick Event Handler

    I am attempting to execute a very simple sql statement based on an onClick event handler. The script processes error free and does everything but call the function the onclick event handler should call. Can anyone look at the script below and let me know what I am doing wrong?

    "<td height=""2"" class=""topicdark"" width=""25%""><b><a href=privatesend.asp?method=Topic&mname=" & rs("T_AUTHOR") & " onClick=""call ReportMeNew(Me)"">Send Warning to Member</a></b></td>" & vbNewline & _


    Sub ReportMeNew(Link)
    sReportSQL = "update from FORUM_TOPICS set T_WARN = T_WARN + 1 " &_
    " where T_AUTHOR= " & AuthorID & " and CAT_ID = " & CatID & " and FORUM_ID = " & ForumID & " and TOPIC_ID = " & TopicID
    my_Conn.Execute (sReportSQL)
    sReportDSQL = "update from FORUM_TOPICS set T_WARNDATE = " & ChkDate(,,true) & "" &_
    " where T_AUTHOR= " & AuthorID & " and CAT_ID = " & CatID & " and FORUM_ID = " & ForumID & " and TOPIC_ID = " & TopicID
    my_Conn.Execute (sReportDSQL)
    End Sub

  • #2
    Senior Coder
    Join Date
    Dec 2002
    Location
    Arlington, Texas USA
    Posts
    1,065
    Thanks
    4
    Thanked 8 Times in 8 Posts
    You are calling server side code on the refering page with a link to another page. the code onclick event cannot work the way you want because it is looking at another page. You will need to add some client side javascript to call this function and then open the link. Or Change it to a button then using the name attribute of the button you can call the function with an if statement looking to see if the button was clicked. If it isn't supposed to change to a different page then definately go with the button.

  • #3
    Senior Coder
    Join Date
    Apr 2003
    Location
    England
    Posts
    1,192
    Thanks
    5
    Thanked 13 Times in 13 Posts
    i thought onclick in asp just called client side .. so if it isnt in <script></script> it shouldnt run it.

  • #4
    New to the CF scene
    Join Date
    Feb 2005
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I do know on Mouse event handlers are no good in asp when attempting to use it to update a db record so I am trying to find an alternative solution. The link is a must because this would require multiple buttons across the page and waste more bandwidth then I could possible care to spend. If anyone can think of an alternative it would be greatly appreciative otherwise I'll keep looking and keep ya'll updated.

  • #5
    Senior Coder
    Join Date
    Apr 2003
    Location
    England
    Posts
    1,192
    Thanks
    5
    Thanked 13 Times in 13 Posts
    cant you just pass what you need to the page it is linked to and run it there, if you can get to those pages in more than one way you could do a referer or querystring check.. alternatively you could send to one page for processing then redirect afterwards to the linked page

  • #6
    New to the CF scene
    Join Date
    Feb 2005
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I can try I suppose....I ain't very good at programming but I'll give it a shot and see if I can figure out how to pass the information onward and call the function there......be back later
    Last edited by TennesseeGuy; 02-08-2005 at 03:46 PM.

  • #7
    Senior Coder
    Join Date
    Dec 2002
    Location
    Arlington, Texas USA
    Posts
    1,065
    Thanks
    4
    Thanked 8 Times in 8 Posts
    does the link point to a new page or does it point back to the same page?

    If it points to a new page move your function to that page and run it from there. If it points back to itself, then make a name attribute to the anchor tag and look for that name attribute in an if statement. put a call to your function inside that if statement. That should solve the problem.

  • #8
    New to the CF scene
    Join Date
    Feb 2005
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I have redone everything into a popup. Everything works with one slight problem. I would like when someone clicks the popup that the popup closes and the redirected page appears in the original parent window. I thought a simple target=""parent"" would do the trick but that just puts the redirect page into the popup window. Any ideas?

  • #9
    Senior Coder
    Join Date
    Apr 2003
    Location
    England
    Posts
    1,192
    Thanks
    5
    Thanked 13 Times in 13 Posts
    this is a javascript problem from here but its not too complicated, it will be answered in any good popup tutorial (eg on dynamic drive) but i am far too lazy to look for it and far too out of practice to answer it myself
    if you dont get any luck here try asking in the javascript section


  •  

    Posting Permissions

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