Re: Auto-tagging in a text box

by "Michael Gerholdt" <gerholdt(at)fredonia.edu>

 Date:  Mon, 12 Mar 2001 20:26:34 -0500
 To:  "Charlton,
Mark" <Mark.Charlton(at)saint-gobain.com>,
<hwg-techniques(at)hwg.org>
 References:  CRYNT40SRV
  todo: View Thread, Original
This would be far simpler simply to do serverside with VBScript.

Just use the response object:

strText = response.form("text_box_name")
strText = Date & " " & strText

Similarly for username. If the person has already logged in, pass that along
in your form as a hidden field

<input type="hidden" name="user" value="loginID">

and pick it up with
strUser = response.form("user")
on the next page.
something like that.

If you do want to use javascript to display the date in the textbox for some
reason with javascript, you don't have to use the onFocus event to do it -
just write it in as the default text with javascript.

this however will be available to the user to edit at will. So the server
side solution above is better.

And a third alternative would be to do it in your sql statement and let SQL
Server do the actual work
something like the following pseudoSQL:

strSQL = "INSERT INTO tablename (field1, field2, field3) values (sysdate ||
'" & strText & "','" & strUser & "',thirdfieldstuff)"

But if you had used the VBScript to put the date into the strText then just
delete this from the sql : sysdate ||

(I don't know MS SQL yet, so this may be slightly different in your use.)

I think, unless there are other considerations, that either of the
serverside solutions are easier and more troublefree than the javascript
clientside approach.

Hope I understand and that this helps!

Mike

> Hi all,
>
> I am currently creating a bug-tracking system of sorts, where multiple
users
> may be adding comments into a textarea. The pages are ASP and feed an MS
SQL
> Server.
>
> What I would like to do is set up a javascript that 'guards' the textarea
so
> as soon as a user clicks into it, it tags the cursor entry point with the
> date. Maybe even with the user (since using this thing requires a login, I
> figure I'll be able to add that into the tagging).
>
> Anyone try anything like this before?
>
> Thanks,
> Imran Zaidi
>

HWG hwg-techniques mailing list archives, maintained by Webmasters @ IWA