Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Why does button onClick code execute when page loads up??

Hi, I need help with this problem i have that the code contained within a BUTTON OnClick event executes when the asp page is loaded and the button is NOT CLICKED. Any advice would be much appreciated.

Basically the code updates a table and opens a pdf file online when the button is clicked.
Here is the code below:-








;window.open('QvarPage1_PIL.pdf')" >

To print this page click here


Comments

  • aaronjones3593aaronjones3593 Member Posts: 122
    [b][red]This message was edited by aaronjones3593 at 2006-3-5 18:36:39[/red][/b][hr]
    : Hi, I need help with this problem i have that the code contained within a BUTTON OnClick event executes when the asp page is loaded and the button is NOT CLICKED. Any advice would be much appreciated.
    :
    : Basically the code updates a table and opens a pdf file online when the button is clicked.
    : Here is the code below:-
    :
    :
    :
    :
    :
    :
    :
    :
    : ;window.open('QvarPage1_PIL.pdf')" >
    :
    : To print this page click here
    :
    :
    :

    ASP Code is executed on the server, so all the server sees is

    [code]
    <%
    Dim loginID
    loginID = request("login")
    Set MyConn = Server.CreateObject("ADODB.Connection")
    MyConn.Open "healthinfo"
    SQL="INSERT INTO PrintLog VALUES ('" & loginID & "','" & Request.ServerVariables("URL") & "','" & Date & "','" & Time & "')"
    Set RS = MyConn.Execute(SQL)
    %>
    [/code]

    which it then executes. The only thing the button would be capable of doing is opening the PDF File. However, when you click the button, you probably get a JavaScript Error don't you? Yup.. because ASP is VBScript not JScript and
    [/code]

    page2.asp:
    [code]
    <%
    Dim loginID
    loginID = request("login")
    Set MyConn = Server.CreateObject("ADODB.Connection")
    MyConn.Open "healthinfo"
    SQL="INSERT INTO PrintLog VALUES ('" & loginID & "','" & Request.ServerVariables("URL") & "','" & Date & "','" & Time & "')"
    Set RS = MyConn.Execute(SQL)
    %>

    window.open('QvarPage1_PIL.pdf');
    history.back();

    [/code]

    That **should** solve your problem.

    -( Aaron )-

    "Alcohol aint the answer, but atleast you forget the question"



  • ceebee1980ceebee1980 Member Posts: 2
    Thanks a lot. It does work now. Cooollll. you rock.
Sign In or Register to comment.