Counting Click Throughs

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

    Counting Click Throughs

    Does anyone know of a quick method of inserting records into a text file or
    database using OnClick?


  • steve stevo

    #2
    Re: Counting Click Throughs

    There is no short cut - you will have to make a request to the server.


    "Smoke" <smoke@xatrium. com> wrote in message
    news:zCtpb.1370 88$sp2.55609@la keread04...[color=blue]
    > Does anyone know of a quick method of inserting records into a text file[/color]
    or[color=blue]
    > database using OnClick?
    >
    >[/color]


    Comment

    • Grant Wagner

      #3
      Re: Counting Click Throughs

      steve stevo wrote:
      [color=blue]
      > There is no short cut - you will have to make a request to the server.
      >
      > "Smoke" <smoke@xatrium. com> wrote in message
      > news:zCtpb.1370 88$sp2.55609@la keread04...[color=green]
      > > Does anyone know of a quick method of inserting records into a text file[/color]
      > or[color=green]
      > > database using OnClick?[/color][/color]

      Assuming the database or text file he wants to insert data into is on the
      server, he has to make a request to the server. However, he can use a variety
      of "shortcuts" which do not involve using POST or GET with a form. Here is a
      simple example:

      <form name="myForm">
      <input type="text" name="theValue" />
      <input type="button" value="Insert" onclick="insert Value(this.form );" />
      </form>
      <script type="text/javascript">
      function insertValue(f) {
      var cgiCaller = new Image();
      cgiCaller.src = 'somethingThatI nsertsTheValue. cgi?theValue=' +
      f.theValue.valu e;
      }
      </script>

      Of course there are obvious disadvantages to doing this. Client-side
      JavaScript has to be enabled, you can't retrieve any sort of information about
      whether the insert was successful or not, etc. I don't recommend doing this
      unless you really don't care if the server did what you just asked it to do,
      but it is an option if that's your requirement.

      The advantages are that you do not need to reload the user's browser, even to
      reload the form, so the user can probably send data to the server as fast as
      they can change the value in the input and click the button.

      The same sort of "shortcut" can be done using the HTTP Request object <url:
      http://jibbering.com/2002/4/httprequest.html />. However, because of the added
      complexity of implementing it, I usually find it easier to POST a form when I
      need to get information back from the server about the state of the
      transaction I just asked it to perform. The additional benefit of a POST or
      GET is that it will still work even if the user has disabled client-side
      JavaScript.

      --
      | Grant Wagner <gwagner@agrico reunited.com>

      * Client-side Javascript and Netscape 4 DOM Reference available at:
      *


      * Internet Explorer DOM Reference available at:
      *
      Gain technical skills through documentation and training, earn certifications and connect with the community


      * Netscape 6/7 DOM Reference available at:
      * http://www.mozilla.org/docs/dom/domref/
      * Tips for upgrading JavaScript for Netscape 7 / Mozilla
      * http://www.mozilla.org/docs/web-deve...upgrade_2.html


      Comment

      Working...