Wrox Programmer Forums
|
Javascript General Javascript discussions.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 13th, 2005, 05:14 AM
Friend of Wrox
 
Join Date: May 2004
Posts: 212
Thanks: 0
Thanked 0 Times in 0 Posts
Default ForAppending

Hi,

I have started a script that appends user responses via select lists to an HTML file. The problem is, it won't append! Here is my code:

function submitq1(){
        var TristateFalse = 0
        var ForAppending = 8
        var selected = document.q1form.sel1.value
    var user1 = parent.opener.document.form1.userID.value
        var theuser = "C:\\path\\" + user1


aXobject = new ActiveXObject("Scripting.FileSystemObject")
        aXobject.CreateTextFile(theuser + ".html")
        file = aXobject.GetFile(theuser + ".html")
        text = file.OpenAsTextStream(ForAppending, TristateFalse)
        text.Write("<br>Q1 was " + selected + "<br>")
        text.Close()
winOpenQ2()
}
function winOpenQ2(){
var win = window.open('c:\\question 2.html', 'Window1', 'resizable=0,height=150,width=400');
}

All it does is replace the original text. Help!

TIA
interrupt

__________________
\'sync\' &lt;cr&gt;
The name specified is not recognized as an internal or external command, operable program or batch file.
 
Old August 13th, 2005, 05:40 AM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

You don't need to create and openAsTextStream:
Code:
var TristateFalse = 0;
var ForAppending = 8;
var oFso = new ActiveXObject("Scripting.FileSystemObject");
var oTS = oFso.openTextFile(<filename>, ForAppending, true, TristateFalse);
oTS.write(<data>);
oTS.close();
--

Joe (Microsoft MVP - XML)









Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.