View Full Version : Log file....
jrmevans
05-15-2003, 10:22 PM
I was wondering if someone could help me...
I am trying to figure out how to have some information, that is type into a text box, be sent to a log file, to review at a later date...
if anyone could help that would be awesome...thanks all....
Vladdy
05-15-2003, 10:31 PM
If you mean "information entered by a visitor reviewed later by you" - that requires server side scripting. If you mean "information entered by a visitor reviewed later by the same visitor" - if this is a small bit you can store it in a cookie on visitor's computer, otherwise you need server side scripting to have all that info on the server
jrmevans
05-15-2003, 11:26 PM
No, sorry, that isn't what I was meaning sorry if I didn't explain it very well.
What I would like to do is to create a text box
In that text box I would like to be able to write information into that text box.
When I am done with the text box I would like to click on a submit button, and have that information saved to a log file, or .txt file. So that when I am need to review that information say 2 day, a week later, I can open my Log file, or .txt file, and the information the I submitted via the text box will be there.
I need this all to take place on the client side.
I am the only who will using the text box. So I will need to store the information locally on my computer.
I hope this clears this up.... anyone else have any suggestions.
cheesebagpipe
05-15-2003, 11:30 PM
Might be helpful:
http://www.vbwm.com/articles/2002/abarfield/hta01/
jrmevans
05-16-2003, 12:30 AM
Log Box (http://members.shaw.ca/jrmevans/codingforums/submitlog.htm)
This is the start of what I was talking about.
The basis of what I would like to do is what I wrritten in the textbox on the link i have listed above.
Hope this helps....
There's some local file writing information in this thread (http://codingforums.com/showthread.php?threadid=17144), which might be what you're looking for.
Well I messed around with this a bit, just to see if it would work...
Here's an HTA example (save it as .hta, instead of .html):
<html>
<head>
<TITLE>Log-Test</TITLE>
<HTA:APPLICATION ID="log"
APPLICATIONNAME="test"
SINGLEINSTANCE="yes"
SYSMENU="yes" />
<style type="text/css">
.field{
height:250px;width:500px;
overflow:auto;}
</style>
<script type="text/jscript">
function addDate(){
var entry = when;
record=new Date();
entry.value = record.toLocaleString();
}
function save()
{
var ForAppending = 8;
var dataFile = "log.txt";
var ts;
var fso =new ActiveXObject("Scripting.FileSystemObject");
ts = fso.OpenTextFile(dataFile,ForAppending,true);
ts.WriteLine('---------------------------------');
ts.WriteLine(when.value);
ts.WriteLine('---------------------------------');
ts.WriteLine();
ts.WriteLine(content.innerText);
ts.WriteLine();
ts.WriteLine();
ts.Close();
}
</script>
</head>
<body>
<div align="center">
<textarea id="content" class="field"></textarea>
<br />
<input type="button" title="Write to file" value="Save" onclick="addDate();save()" />
</div>
<INPUT type="hidden" id="when">
</body>
</html>
If you wanted to do this log-file thing from your website (ie from an .html document), you'd have to specify a path in the code, such as:
var dataFile = "C://log.txt";
You would also have to change your "internet security settings" to accomodate downloading & initializing "unsigned ActiveX controls"...
cheesebagpipe
05-16-2003, 05:37 PM
Somebody posted a link above about .htas...hmm...:D
:thumbsup: yeah, that's one of my favorites...
jrmevans
05-16-2003, 05:45 PM
Okay, i have it created in a HTA file.
I have a log.txt file created on my desktop.
I changed the var dataFile = "C://log.txt";
to a link on my desktop.
nothing writes to that file. just a blank document.
I can't save the file to var dataFile = "C://WINNT\Profiles\james.evans\Desktop\log.txt";
any ideas.
Graeme Hackston
05-16-2003, 05:50 PM
"C://log.txt"
should be
"C:\\log.txt"
liorean
05-16-2003, 05:52 PM
var dataFile="C://WINNT\Profiles\james.evans\Desktop\log.txt"; should be "C:\\WINNT\\Profiles\\james.evans\\Desktop\\log.txt" too...
jrmevans
05-16-2003, 06:07 PM
its all okay.. works awesome... thanks for the help....
I had the path type wrong....
this works
var dataFile = "C://winnt/profiles/james.evans/desktop/log.txt";
jrmevans
05-16-2003, 06:46 PM
I reaaaallly hate to be a pain....but....
any idea for a reset button for the text box...???
That would be easy enough to find if you searched for it (in these forums, perhaps...) ;)
I'm curious: what's your entire concept for this project?
jrmevans
05-16-2003, 11:01 PM
I do tech support for a cable modem company that is based in the states.
The company that i actaully work for holds the contract that I am on support for.
This company is very hard on its agent for handling the call as fast as possible, as accurate as possible, and they grade us on our quality.... and so forth.
I like to be as efficieant(sp) as possible. I want to log my calls, and keep track of the notes that I make, so that I can revert back to them if there is ever an issue where they are saying that I didnt' do something, or did something in accurate that would affect my "standings".
And, not only that, I like to learn how to do all this and I am having fun learning.
I really appreciate everything that everyone here has help me with so far. I dont' actually post a question till I have searched and search for an answer. I like to figure things out for myself.
Thanks again all....
James Evans
Graeme Hackston
05-16-2003, 11:59 PM
Clear textarea:
document.getElementById('content').value = ''
Here's some MSDN pages you might find helpful
fso:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/script56/html/fsooriScriptingRun-TimeReference.asp
hta:
http://msdn.microsoft.com/library/default.asp?url=/workshop/author/hta/hta_node_entry.asp
This might do the trick... just copy & paste the text (in red):
ts.WriteLine('---------------------------------');
ts.WriteLine(when.value);
ts.WriteLine('---------------------------------');
ts.WriteLine();
ts.WriteLine(area.content.innerText);
ts.WriteLine();
ts.WriteLine();
ts.Close();
<div align="center">
<form id="area">
<textarea id="content" class="field"></textarea>
<br />
<input type="reset" onclick="area.content.focus()" />
</form>
<br />
-----------------------------------
Edit >>>
OR...
just do what Graeme suggested, and you only need to add this part--instead of the above form:
ts.Close();
document.getElementById('content').value = '';
content.focus();
}
:D
(this way, the save button will also clear out the textarea...)
:D
jrmevans
05-17-2003, 03:07 AM
Thanks....
I was going to check things out today when I got home, I didnt' have time to look things up while i was work.
Looks like ya beat me to it...LOL...
Again thanks,
James
jrmevans
05-17-2003, 03:26 AM
Works great....
Thanks again.... :) :) :) :)
jrmevans
05-17-2003, 04:21 PM
I have it set up as a link, and when I click on the link to open the .hta file, it asks if I would like to open from location, or save to desktop. I have course have to press open from location, then I can continue on. but I don't want this...
any ideas???
jrmevans
05-17-2003, 04:41 PM
I have it set up as a link, and when I click on the link to open the .hta file, it asks if I would like to open from location, or save to desktop. I have course have to press open from location, then I can continue on. but I don't want this...
any ideas???
This thread (http://codingforums.com/showthread.php?threadid=16467) is about that...
jrmevans
05-19-2003, 06:58 AM
Okay, so now that I have all that worked out, I am trying to merge both my programs together....Now when I am adding my other code to this on, if I add the "form" tag, I get 'when' is undefined. If I take that line out, it work no problem
any ideas?????
<html>
<head>
<TITLE>Log</TITLE>
<HTA:APPLICATION ID="log"
APPLICATIONNAME="test"
SINGLEINSTANCE="no"
SCROLL = "no"
SYSMENU="yes" />
<style type="text/css">
.field{
height:100; width:400;
overflow:auto;}
</style>
<script type="text/jscript">
function addDate(){
var entry = when;
record=new Date();
entry.value = record.toLocaleString();
}
function save()
{
var ForAppending = 8;
var dataFile = "C:/Documents and Settings/James/Desktop/log.txt";
var ts;
var fso =new ActiveXObject("Scripting.FileSystemObject");
ts = fso.OpenTextFile(dataFile,ForAppending,true);
ts.WriteLine('--------------1-------------------');
ts.WriteLine(when.value);
ts.WriteLine('----------------2-----------------');
ts.WriteLine();
ts.WriteLine(notes.innerText);
ts.WriteLine();
ts.WriteLine('-------------3--------------------');
ts.Close();
document.getElementById('notes').value = '';
notes.focus();
}
</script>
</head>
<LINK href="css_files/acsr.css" type=text/css rel=stylesheet>
<LINK href="css_files/acsr.css" type=text/css rel=stylesheet>
<BODY class="" onload="this.resizeTo(650,550)";"return false;" style="background-color:#000000; ">
<FORM name="frm_try">
<INPUT class=formfield2 onClick="bcopy();" type=button value="Copy" style="cursor: hand">
<input class=formfield2 onclick="addDate();save();" type="button" value="Save" style="cursor: hand" />
<input type="hidden" id="when">
<TEXTAREA class=formfield2 name="notes" rows=5 cols=60 ></TEXTAREA>
<br/>
</body>
</html>
cheesebagpipe
05-19-2003, 07:01 AM
function addDate(){
var entry = document.frm_try.when;
.....
Just add a closing form tag here:
<input class=formfield2 onclick="addDate();save();" type="button" value="Save" style="cursor: hand" /></FORM>
or, if you do what cheesebagpipe suggested, you'd also need to change this:
ts.WriteLine(document.frm_try.when.value);
and put your closing form tag after the hidden input...
jrmevans
05-19-2003, 01:40 PM
thanks that was the missing link... makes sense now....LOL
edit...
I guess i jumped the gun on that... thought it made sense.. at least looked like it did...
still doing the same things....
no worries I will figure it out... :)
jrmevans
05-19-2003, 10:23 PM
and now, I would like to thank all who were able to help complete my project that I was working on. It willl help me to my job emensely.
I was able to get things configured correctly, and now both sets of code are combined together, and everythings is working awesome....
but as it goes it is a work in progress....
James Evans
jrmevans
05-20-2003, 01:46 AM
edit...
------------
I figure it out. thanks all.
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.