0
<!DOCTYPE html>
<html>
<head>
<meta charset="EUC-KR">
<title>Insert title here</title>
<script type="text/javascript">
    function doubleAction() {
        var time = new Date().getTime();

        document.boardUploadForm.action = "../ImageUpload/uploadProcess.jsp?time="
                + time;
        document.boardUploadForm.submit();

        document.boardWriteForm.action = "boardProcess.jsp?time=" + time;
        document.boardWriteForm.submit();
    }
</script>
</head>
<body>
    <form name="boardWriteForm" method="post">
        <input type="hidden" name="mode" value="W" />
        <table border="1" summary="BoardWrite">
            <caption>BoardWrite</caption>
            <colgroup>
                <col width="100" />
                <col width="500" />
            </colgroup>
            <tbody>
                <tr>
                    <th align="center">Subject</th>
                    <td><input type="text" name="subject" size="80"
                        maxlength="100" /></td>
                </tr>
                <tr>
                    <td colspan="2"><textarea name="contents" cols="80" rows="10"></textarea>
                        <script>
                            CKEDITOR.replace('contents');
                        </script></td>
                </tr>
            </tbody>
        </table>
    </form>

    <form name="boardUploadForm" method="post"
        enctype="multipart/form-data">
        <table border="1" summary="upload">
            <caption>upload</caption>
            <colgroup>
                <col width="100" />
                <col width="500" />
            </colgroup>
            <tbody>
                <tr>
                    <th align="center">upload</th>
                    <td><input type="file" multiple="multiple" id="filename"
                        name="filename" /></td>
                </tr>
            </tbody>
        </table>
        <p>
            <input type="submit" value="write" onclick="doubleAction();" />
        </p>
    </form>
</body>

this source is a wegpage contain board write and upload file

first form boardWirteForm is for write content

second form boardUploadForm is for upload file

and submit button is trigger function doubleAction()

but just one submit is work other submit is not work

any suggestion?

user2637015
  • 723
  • 2
  • 12
  • 27
  • 2
    Submitting an HTML form causes the page to reload to the form's destination. How do you want to send the browser to two pages at once !?! Consider opening new windows for each, or using AJAX to submit the forms – Shai Nov 29 '13 at 14:28
  • @Shai i want write board with upload file :( – user2637015 Nov 29 '13 at 14:29
  • "I want" doesn't get............. OK, is there any reason you can't just have one form, containing your text boxes and file upload, all sent to the same JSP for processing? If that isn't possible for whatever reason, you'll probably want to use AJAX. – Shai Nov 29 '13 at 14:31
  • @Shai hmm... i try make one form but enctype="multipart/form-data" this tag make error :( thanks for your advice – user2637015 Nov 29 '13 at 14:34
  • One form for all the inputs, using `
    `, should work fine. What error does it give you?
    – Shai Nov 29 '13 at 14:36
  • file request is work fine but request.getParameter("subject") is null – user2637015 Nov 29 '13 at 14:42
  • The very detailed answer at http://stackoverflow.com/a/2424824/1641835 will probably help – Shai Nov 29 '13 at 14:55

1 Answers1

0

You can use Ajax to achieve from within the same function you are calling.

Ajax

Set your own datastring and pass it to each file that you require the POST

If you are uploading files, i'll recommend you to use jQuery Form Plugin.

jQuery Form

function mySubmit(){

// Post 1
    $.ajax({
        type: "POST",
        url: "post1.php",
        datatype: "text",
        success: function(data){
            $("#result").html(data);
        },
    });

// Post 2
    $.ajax({
        type: "POST",
        url: "post2.php",
        datatype: "text",
        success: function(data){
            $("#result2").html(data);
        },
    });

}
DJ22T
  • 1,628
  • 3
  • 34
  • 66