replacing input type=file, click submit twice

Discussions

Web tier: servlets, JSP, Web frameworks: replacing input type=file, click submit twice

  1. replacing input type=file, click submit twice (2 messages)

    I am replacing the default "Browse..." button for input type=file. This works fine except that the form will only submit after the SUBMIT button is clicked twice. Any ideas on why this is happening and how to workaround? Many thanks!

    <html>
    <head></head>
    <body>
    <form name="test_form" method="post" action="test.jsp">
    <input type=file name=browse style="display: none;">
    <input type=text name=file>
    <input type=button value="Select a File..." onClick="browse.click();file.value=browse.value;">

    <!-- must be clicked twice for the form to submit! -->
    <input type=submit value="Submit The Form Now!">
    </form>
    </body>
    </html>
  2. onClick="browse.click();file.value=browse.value;"

    Append 'return true;' in it and it will start working.
  3. Hi, I am also having the same problem with browse.click(); that i have to click the submit button two times. By adding "return true;" to the line - onClick="browse.click();file.value=browse.value;", it is not working.. Is there any way to make it work.