Вы можете подумать, что этот вопрос дублирован, но не потому, что я провел какое-то исследование и попробовал их в своем коде, не получив результата. Мне нужно отправить две формы с одной кнопкой, но кнопка не работает. Код следующий:
<form:form id="cruiseform" modelAttribute="shipcruise" action="cruisepage" method="post"
style="padding:2px;background:#F0F8FF;width:50%;border-top:2px solid #009;
border-bottom:2px solid #009;border-right:2px solid #009;border-left:2px solid #009;margin-left:350px;border-radius:10px">
** <form:label path="cruiseName">Cruise Name</form:label>
<form:input path="cruiseName" type="text" name="cruiseName" required ="required"/>
<form:label path="startDate">Start Date</form:label>
<form:input path="startDate" type="text" name="startDate" placeholder="e.g 2020/1/4" required ="required" />
<form:label path="endDate">End Date</form:label>
<form:input path="endDate" type="text" name="endDate" placeholder="e.g 2020/1/4" required ="required" />
<form:label path="destination">Destination</form:label>
<form:input path="destination" type="text" name="destination" placeholder="Eg. 2 hours" required ="required" />**
</form:form>
другая форма:
<form:form id="bookingform" modelAttribute="bookcruise"
action="cruisePage"
method="post"
style="padding:2px;background:#F0F8FF;width:50%;border-
top:2px solid #009;
border-bottom:2px solid #009;border-right:2px solid
#009;border-left:2px solid
#009;margin-
left:350px;border-radius:10px">
<form:label path="stateroomType"> State Room Type</form:label>
<form:input path="stateroomType" type="text" name="stateroomType" required ="required"/>
<form:label path="totalAmount">Price</form:label>
<form:input path="totalAmount" type="text" name="totalAmount" required ="required" />
<form:label path="totalGuests">Number of Guests</form:label>
<form:input path="totalGuests" type="text" name="totalGuests" required ="required" />
</form:form>
кнопки:
<button type="button" onclick="submitForms()" value="submit"
style="width:100%;border-radius:10px;text-shadow:2px 2px 3px
rgba(150,150,150,0.75);font-family:time">Confirm Your Booking?</button>
<button type="button" value="reset" onclick="resetForms()"
style="width:100%;border-radius:10px;text-shadow:2px 2px 3px
rgba(150,150,150,0.75);font-family:time">Clear</button>
<a href="index.jsp">Cancel</a>
<a href="customer?passengerId=${passengerId}">Modify your profile</a>
javascript код:
<script type="text/javascript">
function submitForms(){
document.submitforms[0].submit();
document.submitforms[1].submit();
}
function resetForms(){
document.submitforms[0].reset();
document.submitforms[1].reset();
}