Click to See Complete Forum and Search --> : File creation and form data problems


trkk
05-07-2003, 07:36 AM
Hi!

I have this code in one asp page and it works fine:

fs = Server.CreateObject("Scripting.FileSystemObject");
st = Server.MapPath ("ab.txt");
txtfile = fs.CreateTextFile (st);

When I try to put this same code to a different asp page in to a function, that should run when a user presses a button, it doesn't work. Anybody know why?

Other problem is that I have to send form data to this function so I could write that data to the file. Is there some other way to do this than like this:

<INPUT TYPE="BUTTON" VALUE="Do" NAME="doo" onClick="xaa(this.form)">

Can I send form data to another form? Or can I send form data to another asp?

Thanks.

gil davis
05-07-2003, 07:45 AM
ASP code runs on the SERVER. You cannot run a server function at the client.

trkk
05-07-2003, 08:01 AM
ok... sorry stupid me...

Anybody know about how to move form data between forms?

slimshady
05-08-2003, 01:49 AM
Please explain what exactly you are trying to accomplish

Jona
05-08-2003, 02:06 AM
Since you're not being clear we can only guess. If you're using ASP, you can send one form's values to another form easily, true? Just remember to provide an alternative for users with Javascript disabled. Eg, don't make forms exclusively submitted with JavaScript, because users with Javascript disabled then, cannot submit the form.

trkk
05-08-2003, 08:22 AM
Ok, I try to explain what I am trying to do. I can't give you an address to look at, because this is run in my firm's intranet.

I have a frame that has 3 parts. On a top frame, there is an a.asp file that has a form which include buttons and
textboxes. In that form I insert data, then press one button and that data is moved to a center frame that has also a form. This works fine.

I am trying to do so that when a user presses another button in a.asp, the data that is in a center frame would be written to a file. Alternatively this could be done by putting that data to the database. Later that file need to be read and values in it brought to this center frame.

Few years ago I wrote this function to a.asp:

<SCRIPT LANGUAGE="JavaScript">
<!--
function x(a)
{
var fso;
var txtfile;
var m;

m = 0;
fso = new ActiveXObject("ADODB.Connection");
fso.Open "db","x", "x"
txtfile = fso.CreateTextFile("x.xml", true);
txtfile.WriteLine ("<document>");

while (m < 50)
{
x = top.frames[1].form2.ta[m].value;


t = m + 1

if (x != "" )
{


txtfile.Write ("<l>");
txtfile.Write (x);
txtfile.WriteLine ("</l>");

m = m + 1;
}
else
{
txtfile.WriteLine ("</document>");

txtfile.Close();
return(0);
}

}

txtfile.WriteLine ("</document>");
txtfile.Close();
fso = nothing

};

//-->
</SCRIPT>

This script dosn't work anymore, thanks to IE6.

I called this function like this: <INPUT TYPE="BUTTON" VALUE="abc" NAME="ee" onClick="x(this.form)">

I think I have to do this by making another form into this a.asp, but then the problem is that I don't realize
how I can send this forms data to that other form inside this same asp file.

I don't use asp.NET.

Hope someone understands what I am trying to do. :-)

Jona
05-08-2003, 09:49 AM
This was done in IE6 because it was a security issue (for example, someone could void your function and write over it temporarily and put anything they wanted in your database--and possibly retreive information as well). You should use an ASP script that writes a file to the database or server, whichever one you choose, instead of using JavaScript. So, in your case, it may be better to ask a question like this in the ASP forum. That is, if you don't know enough ASP to write to a file (and it looks like you probably do). Anyways, you add to a.asp's form page's action (the asp file that processes the form and sends it to b.asp, the middle frame) and put inside of it the write to file script part.