stLeu
stLeu

Reputation: 15

GET-method don´t get the date in the URL

i have a Form with different inputs. Now I call GET and want to give all information to another site.

<form action="/listShifts" method="GET">
                            <div class="row">
                                <div class="m-1 col-sm-3">
                                    <label class="control-label"><spring:message
                                            code="shifts.startdate"/></label>
                                    <input type="date" class="form-control" value="">
                                </div>
                                <div class="m-1 col-sm-3">
                                    <label class="control-label"><spring:message
                                            code="shifts.enddate"/></label>
                                    <input type="date" class="form-control" value="">
                                </div>
                                <div class="m-1 col-sm-3">
                                    <label class="control-label"><spring:message
                                            code="shiftstatus.name"/></label>
                                    <select name="stateId" class="form-control">
                                        <option value=""><spring:message code="shifts.selectshiftstate"/></option>
                                        <option value=""><spring:message code="shifts.allstates"/></option>
                                        <c:forEach items="${states}" var="state">
                                            <option value="${state.stateId}">${state.stateName}</option>
                                        </c:forEach>
                                    </select>
                                </div>
                            <button type="submit" class="mt-4 btn btn-outline-info align-self-center"><spring:message
                                    code="shifts.filter2"/></button>

                        </form>

The state ID is written to the URL. The date not. How can i change this? Don´t know how to fix that problem.

Upvotes: 1

Views: 51

Answers (1)

BadPiggie
BadPiggie

Reputation: 6359

You need to add name parameter to your inputs to submit through forms. If you want to submit date, Just add name attribute to your date field.

<div class="m-1 col-sm-3">
     <label class="control-label">
        <spring:message code="shifts.startdate"/>
     </label>
     <input type="date" class="form-control" value="" name="start_date">
</div>
<div class="m-1 col-sm-3">
     <label class="control-label">
        <spring:message code="shifts.enddate"/>
     </label>
     <input type="date" class="form-control" value="" name="end_date">
</div>

Now, you are getting only state, Because you added name attribute only to your state dropdown.

<select name="stateId" class="form-control">
 ...

Upvotes: 3

Related Questions