Results 1 to 11 of 11

Thread: Urgent Help

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Dec 2000
    Posts
    135

    Arrow

    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!!

  2. #2

    Thread Starter
    Addicted Member
    Join Date
    Dec 2000
    Posts
    135
    REWARD FOR SUCCESS

  3. #3
    Addicted Member Xenonic_Rob's Avatar
    Join Date
    Jun 2000
    Location
    England, UK
    Posts
    213
    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?

    Rob Wright
    E-mail: [email protected]
    Website: http://www.xenonic.com
    The First Member of Honeybee's Club
    Favourite words: Zugzwang and Empiric

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Dec 2000
    Posts
    135
    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!

  5. #5
    Addicted Member Xenonic_Rob's Avatar
    Join Date
    Jun 2000
    Location
    England, UK
    Posts
    213
    Mmm... let me see what I can do.
    What's the deadline?

    Rob Wright
    E-mail: [email protected]
    Website: http://www.xenonic.com
    The First Member of Honeybee's Club
    Favourite words: Zugzwang and Empiric

  6. #6

    Thread Starter
    Addicted Member
    Join Date
    Dec 2000
    Posts
    135
    the sooner the better thanx for your help! it shouldent be too hard

  7. #7

    Thread Starter
    Addicted Member
    Join Date
    Dec 2000
    Posts
    135
    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

  8. #8

    Thread Starter
    Addicted Member
    Join Date
    Dec 2000
    Posts
    135
    hi just wanted to know how the script is goin
    again tanx alot

  9. #9

    Thread Starter
    Addicted Member
    Join Date
    Dec 2000
    Posts
    135
    Hello whats going on

  10. #10
    Fanatic Member Jerry Grant's Avatar
    Join Date
    Jul 2000
    Location
    Dorset, UK
    Posts
    810
    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!
    Jerry Grant................tnarG yrreJ
    Website: <JG-Design></.net>
    Email: [email protected]
    Working towards a bug free world......
    (Not a Microsoft employee)

  11. #11

    Thread Starter
    Addicted Member
    Join Date
    Dec 2000
    Posts
    135

    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
  •  



Click Here to Expand Forum to Full Width