這裏的圖片 http://imgur.com/a/4gP06 我基本上希望 - 按鈕被直接留在「1」和+的權利「1」。 正在使用彈簧模型中的數據填充行。試圖保持在同一水平線上的兩個按鈕和段落在同一行在表
<table class="table table-striped">
<thead>
<tr>
<th>Product</th>
<th>Quantity</th>
<th>Price</th>
<th>Total Price</th>
<th></th>
</tr>
</thead>
<tbody>
<tr th:each="cartLine : ${cartLines}">
<td>
<a th:href="@{|/product/${cartLine.product.id}|}" th:text="${cartLine.product.title}"></a>
</td>
<td>
<p>
<form th:action="@{|/cart/decrease/${cartLine.product.id}|}" method="post">
<input type="submit" class="btn btn-primary" id="decreaseCartLine" value="-"/>
</form>
<p th:text="${cartLine.quantity}"></p>
<form th:action="@{|/cart/increase/${cartLine.product.id}|}" method="post">
<input type="submit" class="btn btn-primary" id="increaseCartLine" value="+"/>
</form>
</p>
</td>
<td th:text="${cartLine.product.price}">price</td>
<td th:text="${cartLine.totalPrice}">total price</td>
<td><form th:action="@{|/cart/remove/${cartLine.product.id}|}" method="post">
<input type="submit" class="btn btn-primary" id="removeCartLine" value="Remove Item"/>
</form>
</td>
</tr>
</tbody>
</table>
+和 - 應該是我的服務器的後請求,確保有足夠的股票等,不知道從那個例子到這樣做去哪裏 – Daniel
在演示查看JS代碼。在那裏你可以根據你的需要編輯代碼,你可以通過在按鈕上使用點擊事件來獲得輸入的值,然後發出一個AJAX請求來更新它。 –
不幸的是我的代碼重寫爲AJAX(還有其他的東西要更新像購物車總等)和我的控制器的發佈請求,只是讓一些按鈕保持在一行似乎不是正確的解決方案 – Daniel