Slattery, Tim - BLS wrote:
You are a life saver. This is so cool. However, the "browse" button in this case is not a browse button but, rather, a submit button. Can you leave this as it is and also give us a submit button? Thanks a ton. This should show my partners in this crime that a submit is definitely possible.
I don't understand what you're asking. True, in the form in the previous
letter there's no "submit" button, therefore no way to submit it. So just
add an <input type="submit"...> element. The user sees the image, when he
clicks it, the Javascript causes the <input type="file"...> element to
operate, and the user selects a file. After the file is selected the
Javascript copies the file name to the visible <input type="file"...>
element. When the form is submitted, the file is sent up.
Come to think of it, you'll need to add enctype="multipart/form-data" to the "<form..." element. And, of course, you'll need something on the server end that can handle what's coming up. Struts has what's necessary.
-- Tim Slattery [EMAIL PROTECTED]
That's not the problem, Tim. If we use yours it does not browse when we click browse but submits when we click browse. More below:
Given what you have suggested and standard form, these are the outputs, once we add what is needed and manually put the browse location into the text box for your form, i.e. manually add "C:\jakarta-service.log" because there is no browse button with yours:
YOUR SUGGESTION RESULT = tim.jsp?browse=jakarta-service.log&submit.x=20&submit.y=6
STANDARD FORM RESULT = tim.jsp?browse=&file=C%3A%5Cjakarta-service.log&x=21&y=7
Yours is returning the file location as the coordinates and name of the submit button and an empty value for the file name. A
<script language="javascript>" function getFile() { o = document.getElementById("browse"); 0.click(); document.getElementById("file").value = o.value; } </script>
<form method="get" action="tim.jsp" enctype="multi-part/form"> <input type="file" name="browse" id="browse" style="display:none"> <input type="text" name="file" id="file"> <input type="image" onClick="getFile()" src="submit.gif"> </form>
<form method="get" action="tim.jsp" enctype="multi-part/form"> <input type="file" name="browse"> <input type="image" name="submit" src="submit.gif"> </form>
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]