OnClick Question

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • SyrU

    OnClick Question

    I have the below code. I am trying to send information to a subroutine, I
    am getting an Object Required Error.

    <input type="button" name="pSearch" value="Search"
    onclick="Displa yRecords()">

    Then in my ASP page I have this

    Sub DisplayRecords( )

    dim conn
    dim strsql
    dim mycount

    ....
    ....

    End Sub

    I think I am doing this correctly.



  • Coz

    #2
    Re: OnClick Question

    You seem to be confusing a client side event (onClick) with server side
    script.

    "SyrU" <dthmtlgod@hotm ail.com> wrote in message
    news:u4k0HBHjEH A.2652@TK2MSFTN GP15.phx.gbl...[color=blue]
    > I have the below code. I am trying to send information to a subroutine, I
    > am getting an Object Required Error.
    >
    > <input type="button" name="pSearch" value="Search"
    > onclick="Displa yRecords()">
    >
    > Then in my ASP page I have this
    >
    > Sub DisplayRecords( )
    >
    > dim conn
    > dim strsql
    > dim mycount
    >
    > ...
    > ...
    >
    > End Sub
    >
    > I think I am doing this correctly.
    >
    >
    >[/color]


    Comment

    • Curt_C [MVP]

      #3
      Re: OnClick Question

      the event is CLIENT side, your code is SERVER side, they can't interact.
      You'll have to post to the server and process from there.

      --
      Curt Christianson
      Owner/Lead Developer, DF-Software
      Site: http://www.Darkfalz.com
      Blog: http://blog.Darkfalz.com


      "SyrU" <dthmtlgod@hotm ail.com> wrote in message
      news:u4k0HBHjEH A.2652@TK2MSFTN GP15.phx.gbl...[color=blue]
      >I have the below code. I am trying to send information to a subroutine, I
      > am getting an Object Required Error.
      >
      > <input type="button" name="pSearch" value="Search"
      > onclick="Displa yRecords()">
      >
      > Then in my ASP page I have this
      >
      > Sub DisplayRecords( )
      >
      > dim conn
      > dim strsql
      > dim mycount
      >
      > ...
      > ...
      >
      > End Sub
      >
      > I think I am doing this correctly.
      >
      >
      >[/color]


      Comment

      • SyrU

        #4
        Re: OnClick Question

        Hmmm, thanks didn't realize that. Is there any another way I can have a
        user click on a button and run a sub routine or do I have to pass the value
        to another page?.


        "Curt_C [MVP]" <software_AT_da rkfalz.com> wrote in message
        news:O94OVLHjEH A.712@TK2MSFTNG P09.phx.gbl...[color=blue]
        > the event is CLIENT side, your code is SERVER side, they can't interact.
        > You'll have to post to the server and process from there.
        >
        > --
        > Curt Christianson
        > Owner/Lead Developer, DF-Software
        > Site: http://www.Darkfalz.com
        > Blog: http://blog.Darkfalz.com
        >
        >
        > "SyrU" <dthmtlgod@hotm ail.com> wrote in message
        > news:u4k0HBHjEH A.2652@TK2MSFTN GP15.phx.gbl...[color=green]
        > >I have the below code. I am trying to send information to a subroutine,[/color][/color]
        I[color=blue][color=green]
        > > am getting an Object Required Error.
        > >
        > > <input type="button" name="pSearch" value="Search"
        > > onclick="Displa yRecords()">
        > >
        > > Then in my ASP page I have this
        > >
        > > Sub DisplayRecords( )
        > >
        > > dim conn
        > > dim strsql
        > > dim mycount
        > >
        > > ...
        > > ...
        > >
        > > End Sub
        > >
        > > I think I am doing this correctly.
        > >
        > >
        > >[/color]
        >
        >[/color]


        Comment

        • Ray Costanzo [MVP]

          #5
          Re: OnClick Question

          It can be the same page, different page, different server, different site -
          it doesn't matter. But, regardless, you'll have to hit a server again.
          Example:


          <%
          If Request.Queryst ring("x") = "1" Then
          Response.Write "Okay, NOW the code in here will run..."
          '''code, code, code
          End If
          %>


          <button onclick="locati on.href+='?x=1' ">Run a sub</button>


          See, instead of calling a sub from your button, you call the page again, but
          pass something in the querystring that can tell your SERVER-side code that
          it should do something. Does that make sense at all?

          Ray at home



          "SyrU" <dthmtlgod@hotm ail.com> wrote in message
          news:%23etnSgIj EHA.1776@TK2MSF TNGP15.phx.gbl. ..[color=blue]
          > Hmmm, thanks didn't realize that. Is there any another way I can have a
          > user click on a button and run a sub routine or do I have to pass the[/color]
          value[color=blue]
          > to another page?.
          >
          >
          > "Curt_C [MVP]" <software_AT_da rkfalz.com> wrote in message
          > news:O94OVLHjEH A.712@TK2MSFTNG P09.phx.gbl...[color=green]
          > > the event is CLIENT side, your code is SERVER side, they can't interact.
          > > You'll have to post to the server and process from there.
          > >
          > > --
          > > Curt Christianson
          > > Owner/Lead Developer, DF-Software
          > > Site: http://www.Darkfalz.com
          > > Blog: http://blog.Darkfalz.com
          > >
          > >
          > > "SyrU" <dthmtlgod@hotm ail.com> wrote in message
          > > news:u4k0HBHjEH A.2652@TK2MSFTN GP15.phx.gbl...[color=darkred]
          > > >I have the below code. I am trying to send information to a[/color][/color][/color]
          subroutine,[color=blue]
          > I[color=green][color=darkred]
          > > > am getting an Object Required Error.
          > > >
          > > > <input type="button" name="pSearch" value="Search"
          > > > onclick="Displa yRecords()">
          > > >
          > > > Then in my ASP page I have this
          > > >
          > > > Sub DisplayRecords( )
          > > >
          > > > dim conn
          > > > dim strsql
          > > > dim mycount
          > > >
          > > > ...
          > > > ...
          > > >
          > > > End Sub
          > > >
          > > > I think I am doing this correctly.
          > > >
          > > >
          > > >[/color]
          > >
          > >[/color]
          >
          >[/color]


          Comment

          • SyrU

            #6
            Re: OnClick Question

            Yes, it does. Thanks Ray


            "Ray Costanzo [MVP]" <my first name at lane 34 dot commercial> wrote in
            message news:eo%23yhSKj EHA.644@tk2msft ngp13.phx.gbl.. .[color=blue]
            > It can be the same page, different page, different server, different[/color]
            site -[color=blue]
            > it doesn't matter. But, regardless, you'll have to hit a server again.
            > Example:
            >
            >
            > <%
            > If Request.Queryst ring("x") = "1" Then
            > Response.Write "Okay, NOW the code in here will run..."
            > '''code, code, code
            > End If
            > %>
            >
            >
            > <button onclick="locati on.href+='?x=1' ">Run a sub</button>
            >
            >
            > See, instead of calling a sub from your button, you call the page again,[/color]
            but[color=blue]
            > pass something in the querystring that can tell your SERVER-side code that
            > it should do something. Does that make sense at all?
            >
            > Ray at home
            >
            >
            >
            > "SyrU" <dthmtlgod@hotm ail.com> wrote in message
            > news:%23etnSgIj EHA.1776@TK2MSF TNGP15.phx.gbl. ..[color=green]
            > > Hmmm, thanks didn't realize that. Is there any another way I can have a
            > > user click on a button and run a sub routine or do I have to pass the[/color]
            > value[color=green]
            > > to another page?.
            > >
            > >
            > > "Curt_C [MVP]" <software_AT_da rkfalz.com> wrote in message
            > > news:O94OVLHjEH A.712@TK2MSFTNG P09.phx.gbl...[color=darkred]
            > > > the event is CLIENT side, your code is SERVER side, they can't[/color][/color][/color]
            interact.[color=blue][color=green][color=darkred]
            > > > You'll have to post to the server and process from there.
            > > >
            > > > --
            > > > Curt Christianson
            > > > Owner/Lead Developer, DF-Software
            > > > Site: http://www.Darkfalz.com
            > > > Blog: http://blog.Darkfalz.com
            > > >
            > > >
            > > > "SyrU" <dthmtlgod@hotm ail.com> wrote in message
            > > > news:u4k0HBHjEH A.2652@TK2MSFTN GP15.phx.gbl...
            > > > >I have the below code. I am trying to send information to a[/color][/color]
            > subroutine,[color=green]
            > > I[color=darkred]
            > > > > am getting an Object Required Error.
            > > > >
            > > > > <input type="button" name="pSearch" value="Search"
            > > > > onclick="Displa yRecords()">
            > > > >
            > > > > Then in my ASP page I have this
            > > > >
            > > > > Sub DisplayRecords( )
            > > > >
            > > > > dim conn
            > > > > dim strsql
            > > > > dim mycount
            > > > >
            > > > > ...
            > > > > ...
            > > > >
            > > > > End Sub
            > > > >
            > > > > I think I am doing this correctly.
            > > > >
            > > > >
            > > > >
            > > >
            > > >[/color]
            > >
            > >[/color]
            >
            >[/color]


            Comment

            Working...