Passing File Path through JavaScript in an ASP Web Utility

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • NobodyImportant
    New Member
    • Mar 2008
    • 2

    Passing File Path through JavaScript in an ASP Web Utility

    Hello everyone! I admit up front that I am new at this and have very little knowledge of JavaScript, but we have an asp web form that allows for the manipulation of letters our company regularly uses. In the administration of this web utility, a user can update the file path of a Word document. Here is the relevant asp code for the admin page:

    Code:
    		while not rst.EOF
    			%>
    
    						<input type=hidden name=letterid value=<%=rst("ql_guid")%>>
    						<tr bgcolor=<%=bgcolor%>>
    							<form name=do_list_update&mycount action=index.asp method=post>
    							<input type=hidden name=mode value='update_list'>
    							<input type=hidden name=myguide value='<%=rst("ql_guid")%>'>
    							<input type=hidden name=filepath value="">
    							<td width="20%"><input name=letter_name value='<%=rst("ql_name")%>' size=25></td>
    							<td width="40%"><%=rst("ql_path")%></td>
    							<td width="20%"><input type=file size=30 name=letter_path value=<%=Request("filepath")%>></td>
    							<td width="10%" align="center"><input type=submit onClick="copyFilePathData()" value='Update'></td>
    							</form>
    							<td width="5%" align="center"><a href='file:///<%=rst("ql_path")%>'>EDIT</a></td>
    							<td width="5%" align="center"><a href="index.asp?mode=del_gl2&myguide=<%=rst("ql_guid")%>">DELETE</a></td></tr>						
    			<%					
    				rst.movenext
    		wend
    The problem is that without a JavaScript function, this form will not keep the path for variable letter_path. I was told that I needed an onClick call to a basic JavaScript to keep the file path in the variable (FilePathData). Here is the script:

    Code:
    <script LANGUAGE="JavaScript">
    function copyFilePathData()
    {
    	do_list_update.filepath.value = do_list_update.letter_path.value
    }
    </script>
    So here is my problem: as you can see, given the loop nature of the form, its name changes. How can I properly modify this JavaScript to keep the file path? I cannot get the current script to work with the dynamic form name, leaving the variable letter_path with just the filename, minus the path.
  • acoder
    Recognized Expert MVP
    • Nov 2006
    • 16032

    #2
    Call the function by passing the form object:[CODE=html]<input type=submit onClick="copyFi lePathData(this .form)" value='Update'>[/CODE]Then change the function to this:
    [CODE=javascript]
    <script type="text/javascript">
    function copyFilePathDat a(frm)
    {
    frm.filepath.va lue = frm.letter_path .value
    }
    </script>
    [/CODE]

    Comment

    • NobodyImportant
      New Member
      • Mar 2008
      • 2

      #3
      Thank you acoder! That did the trick.

      Comment

      • acoder
        Recognized Expert MVP
        • Nov 2006
        • 16032

        #4
        No problem, you're welcome. Post again if you have any more questions! Nobody's unimportant ;)

        Comment

        Working...