Home >Web Front-end >HTML Tutorial >s:iterator dynamic display input box problem_html/css_WEB-ITnose
The jsp code and page are as follows
<body ><br> <div align="center"> <a href="listAllDataInfo">显示所有</a> <table width="500" border="1" class="table"> <tbody align="center"> <tr> <td colspan="5" style="font-size: 20;">指标信息</td> <tr> <td width="105">指标编码</td> <td width="300">指标名称</td> <td>填写数值</td> </tr> <!--循环显示记录部分 --> <s:iterator value="list" > <tr class="br_TR"> <td><s:property value="indexCode"/></td> <td><s:property value="indexName"/></td> <td><input name="" /></td> </s:iterator> </tbody> </table> </div> </body>
When iterating, add an ID to each INPUT element, and then add a button to get all INPUT after clicking it. The value is sent to the backend for storage.
When iterating, add an ID to each INPUT element, and then add a button. After clicking, get the value of all INPUT and send it to the backend for storage.
When iterating, add an ID to each INPUT element, and then add a button. After clicking, get the value of all INPUT and send it to the backend for storage.
<body ><br> <div align="center"> <a href="listAllDataInfo">显示所有</a> <table width="500" border="1" class="table"> <tbody align="center"> <tr> <td colspan="5" style="font-size: 20;">指标信息</td> <tr> <td width="105">指标编码</td> <td width="300">指标名称</td> <td>填写数值</td> </tr> <!--循环显示记录部分 --> <s:iterator value="list" > <tr class="br_TR"> <td><s:property value="indexCode"/></td> <td><s:property value="indexName"/></td> <td><input id="<s:property value="indexCode"/>" /></td> </s:iterator> </tbody> </table> </div> </body>
When iterating, add an ID to each INPUT element, and then add a button. After clicking, get the value of all INPUT and send it to Save on the end.
I don’t understand your needs. Don’t you want to save the value in the input to the database? Where to store it depends entirely on how your backend runs. JS does not store the database, it can only send requests to the backend for processing.
I don’t understand your needs. Don’t you want to save the value in the input to the database? Where to store it depends entirely on how your backend runs. JS does not store the database, it can only send requests to the backend for processing.
<s:form action="updateAllDataInfo" method="post"> <table width="500" border="1" class="table"> <tbody align="center"> <tr> <td colspan="5" style="font-size: 20;">指标信息</td> </tr> <tr> <td width="105">指标编码</td> <td width="300">指标名称</td> <td>填写数值</td> </tr> <!--循环显示记录部分 --> <s:iterator value="list" status="status" > <tr > <td><s:property value="indexCode"/></td> <td><s:property value="indexName"/></td> <td><input type="text" name="dataInfoList[#status.index].indexValue" style="width:100"/></td> </tr> </s:iterator> <s:submit value="保存" align="center" />
public String updateAll() throws Exception{ System.out.println("开始"); // List<IndexInfo> list = (List<IndexInfo>)session.get("list"); for(int i = 0; i < dataInfoList.size(); i++) { dataInfoBiz.addDataInfo(dataInfoList.get(i)); } return this.listAll(); }
I suggest you the best Debug both the front-end and the back-end to see what the format of the data sent by the front-end is, and then the back-end obtains the data according to the format.