Link to home
Start Free TrialLog in
Avatar of elliottbenzle
elliottbenzle

asked on

why can I only call the function one time

I'm using ASP VBScript and I'm trying to create an upload page where I put the file name into a function and then display the function in a text field. There are two parts of the code, one which displays the name  and one which puts the code into the initial value of the text field. For some reason if I use the function in the "response.write" it will no longer display in the text field, if I erase the response.write part then the initial value displays correctly. Why will the function value not display in both places? Can I only use the function once? What am I not understanding? Below is the code, the functin name is "SaveFileName". Please let me know if you need more information. thanks.

<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<  Set Function  >>>>>>>>>>>>>>>>>>
function SaveFileName
    Dim Upload, fileName, ks, i, fileKey

    Set Upload = New FreeASPUpload
    Upload.Save(uploadsDirVar)

      ' If something fails inside the script, but the exception is handled
      If Err.Number<>0 then Exit function

    SaveFileName = ""
    ks = Upload.UploadedFiles.keys
    if (UBound(ks) <> -1) then
        SaveFileName = ""
        for each fileKey in Upload.UploadedFiles.keys
            SaveFileName = SaveFileName & Upload.UploadedFiles(fileKey).FileName  
        next
    else
    end if
end function

<<<<<<<<<<<<<<<<<<<< display save file in text  "response.write">>>>>>>>>>>>>>>>>>>>>>>>
<%
Dim diagnostics
if Request.ServerVariables("REQUEST_METHOD") <> "POST" then
    diagnostics = TestEnvironment()
    if diagnostics<>"" then
        response.write "<div style=""margin-left:20; margin-top:30; margin-right:30; margin-bottom:30;"">"
        response.write diagnostics
        response.write "<p>After you correct this problem, reload the page."
        response.write "</div>"
    else
        response.write "<div style=""margin-left:150"">"
        OutputForm()
            OutputForm()
        response.write "</div>"
    end if
else
    response.write "<div style=""margin-left:150"">"
    OutputForm()
      response.write SaveFileName()
    response.write "<br><br></div>"
end if

%>

<<<<<<<<<<<<<<<<<<<<<<<< put function in text field >>>>>>>>>>>>>>>>>>>>>>>>

<form action="<%=MM_editAction%>" method="POST" name="datainput" id="datainput">
  <label>
  <input name="picture" type="text" id="picture" value="<%=SaveFileName()%>">
  </label>
  <label>
  <input type="submit" name="Submit" value="Submit">
</label>
  <input type="hidden" name="MM_insert" value="datainput">
</form>
ASKER CERTIFIED SOLUTION
Avatar of Rouchie
Rouchie
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial