|
-
Feb 3rd, 2001, 07:25 PM
#1
Thread Starter
Addicted Member
can someone write me a script in any laguage as long as u tell me of a FREE host that the script will run on and how to install it! the script must take 5 values from a form and post them in a text file seperated by commas and and like so:
value1,value2,value3,value4,value5
value1,value2,value3,value4,value5
every submittin is on a new line so if the submit a full form than an empty form then a full form the text file would look like this:
value1,value2,value3,value4,value5
,,,,
value1,value2,value3,value4,value5
that should be simple! however it get a bit complicated
when the form is submitted it searches all the valueones for a match with the valueone being submitted. if there is a match the line that contains the OLD valueone in the textfile get deleted and the NEW line is added to the text file.
if you have any questions PLEASE post them i really need this script as soon as possible! thanx in advanced!
Reward if successful!!
-
Feb 5th, 2001, 04:33 PM
#2
Thread Starter
Addicted Member
-
Feb 11th, 2001, 03:40 PM
#3
Addicted Member
OK, I might be able to help you Sam, but first, does it expressly need to be a text file? Can it be an Access database?
-
Feb 12th, 2001, 10:56 PM
#4
Thread Starter
Addicted Member
It can be anything! but a text file would be better do u think u can do it sorry but i dont got the reward anymore!
-
Feb 13th, 2001, 01:09 PM
#5
Addicted Member
Mmm... let me see what I can do.
What's the deadline?
-
Feb 13th, 2001, 03:56 PM
#6
Thread Starter
Addicted Member
the sooner the better thanx for your help! it shouldent be too hard
-
Feb 13th, 2001, 03:57 PM
#7
Thread Starter
Addicted Member
it would be nice if the number of values wasnt fixed i could use this script for more than one thing!
thanx again for all your help
-
Feb 15th, 2001, 03:31 PM
#8
Thread Starter
Addicted Member
hi just wanted to know how the script is goin
again tanx alot
-
Feb 19th, 2001, 06:24 PM
#9
Thread Starter
Addicted Member
-
Feb 20th, 2001, 10:34 AM
#10
Fanatic Member
I have written some script which should address your request.
It's a bit untidy but gives you the basis of what you require:
Create a HTML page called Inputs.htm and paste in the following code:
Code:
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
<TITLE>Input data into the text boxes....</TITLE>
</HEAD>
<SCRIPT Language="JScript">
<!--
var inprogress;
function DoSubmit(sessionid)
{
if (inprogress == "True")
{
alert("Submission is being processed, please wait");
return (false);
}
inprogress = "True";
window.location.href="Process.asp?T1="
+ oForm.oText1.value
+ "&T2=" + oForm.oText2.value
+ "&T3=" + oForm.oText3.value
+ "&T4=" + oForm.oText4.value
+ "&T5=" + oForm.oText5.value;
}
-->
</SCRIPT>
<BODY>
<FORM name="oForm">
<P>
<TABLE cellSpacing=2 cellPadding=2 border=0>
<TR>
<TD>Input No 1 </TD>
<TD><INPUT id=text1 name=oText1></TD>
</TR>
<TR>
<TD>Input No 2 </TD>
<TD><INPUT id=text2 name=oText2></TD>
</TR>
<TR>
<TD>Input No 3 </TD>
<TD><INPUT id=text3 name=oText3></TD>
</TR>
<TR>
<TD>Input No 4 </TD>
<TD><INPUT id=text4 name=oText4></TD>
</TR>
<TR>
<TD>Input No 5 </TD>
<TD><INPUT id=text5 name=oText5></TD>
</TR>
</TABLE></P>
<INPUT type="button" style="width:75px" value="Submit" onclick="DoSubmit()"></INPUT>
<FORM>
</BODY>
</HTML>
Create an ASP page called Process.ASP and paste in the following code:
Code:
<html>
<title>Processing data from Inputs.htm</title>
<BODY>
<%@ Language=VBScript%>
<%
Const ForReading = 1, ForWriting = 2, ForAppending = 8
Dim sData
Dim iFile '== Input File
Dim oFile '== Output File
Dim TextStream
Dim sLine '== File line
Dim updateFlag
Dim sSplit
updateFlag = 0
sData = Request.QueryString("T1") & "," & _
Request.QueryString("T2") & "," & _
Request.QueryString("T3") & "," & _
Request.QueryString("T4") & "," & _
Request.QueryString("T5")
Set fso = CreateObject("Scripting.FileSystemObject")
If fso.FileExists("C:\myData.html") Then
Set iFile = fso.GetFile("C:\myData.html")
Else
Set iFile = fso.CreateTextFile("C:\myData.html", True)
iFile.WriteLine("'=== Input Data file ==='")
iFile.Close
Set iFile = fso.GetFile("C:\myData.html")
End If
Set TextStream = iFile.OpenAsTextStream(ForReading)
'=== Create a temporary file to put data into
Set oFile = fso.CreateTextFile("C:\myTemp.html", True)
Do While Not TextStream.AtEndOfStream
'=== Get the next line from the file
sLine = TextStream.ReadLine
Select Case sLine
Case "'=== Input Data file ==='"
Response.Write "<font color='Blue'>" & sLine & "</font><br>"
oFile.WriteLine sLine
Case ""
'=== Enter whatever lines you want to ignore in separate expressionlists
Case Else
sSplit = Split(sLine, ",")
'=== Check the first item for a duplicate
If Trim(sSplit(0)) = Trim(Request.QueryString("T1")) Then
Response.Write "<font color='Red'>" & sData & "</font><br>"
oFile.WriteLine sData
updateFlag = 1
Else
Response.Write sLine & "<br>"
oFile.WriteLine sLine
End If
End Select
Loop
TextStream.Close
'=== If the record was not found in the file then add it now
If updateFlag = 0 Then
Response.Write "<font color='Red'>" & sData & "</font><br>"
oFile.WriteLine sData
End If
Response.Write "<font color='Blue'>The item in red represents a new entry or updated existing item.</font><br>"
oFile.Close
fso.CopyFile "C:\myTemp.html", "C:\myData.html", True
fso.DeleteFile "C:\myTemp.html", True
Set fso = Nothing
%>
</BODY>
</HTML>
Put both files into a IIS folder, then call the Inputs.htm.
You can improve this if you use Server.MapPath("myData.htm") so you can get to the file from a remote server
Is this all understandable? Let me know how you get on!
-
Feb 25th, 2001, 02:23 PM
#11
Thread Starter
Addicted Member
THANX
thank you so much!!!!!!!! i havnt tryed it yet i just got my connection back (stupid cable service) ill tell u how it goes! do i have to upload this to a cgi accepting host or does it matter?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|