欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

利用js實(shí)現(xiàn)前臺(tái)動(dòng)態(tài)添加文本框,后臺(tái)獲取文本框內(nèi)容(示例代碼)

 更新時(shí)間:2013年11月25日 09:45:14   投稿:jingxian  
這篇文章主要是對(duì)利用js實(shí)現(xiàn)前臺(tái)動(dòng)態(tài)添加文本框,后臺(tái)獲取文本框內(nèi)容的示例代碼進(jìn)行了介紹,需要的朋友可以過來參考下,希望對(duì)大家有所幫助

一共兩個(gè)頁面,分別如下:

一.創(chuàng)建頁面create.jsp

復(fù)制代碼 代碼如下:

<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html>
<title>
</title>
<head>
</head>
<body >
 <form id="form1" action="request.jsp">
<script language="javascript" type="text/javascript">

var count=0 ;
function additem(id)
{
  var row,cell,str;
  row = document.getElementByIdx_x(id).insertRow();
  if(row != null )
  {
cell = row.insertCell();
cell.innerHTML="<input id=\"St"+count+"\" type=\"text\" name=\"St"+count+"\" value= \"St"+count+"\"><input type=\"button\" value=\"刪除\" onclick=\'deleteitem(this);\'>";
count ++;
  }
}
function deleteitem(obj)
{
  var curRow = obj.parentNode.parentNode;
  tb.deleteRow(curRow.rowIndex);
}

function getsub()
{
var re="";
for (var  i = 0 ;i<count;i++)
{
re += document.getElementsByName("St"+i)[0].value;

}
document.getElementByIdx_x("Hidden1").value=re;
}


</script><table id="tb"></table>
<input name="button" type="button" onclick='additem("tb")' value="添加>>"/><input type="submit" name="submit" onclick="getsub()" value="提交"/>
    <input id="Hidden1" name="Hidden1" type="hidden" value="" />
    </form>
</body>

</html>


二.接收數(shù)據(jù)頁面 request.jsp
復(fù)制代碼 代碼如下:

<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>

<html>
  <head>
 
    <title>測(cè)試</title>

  </head>
  <%
   String data= request.getParameter("Hidden1");
   out.println("取得的數(shù)據(jù)為:"+data);
   %>
  <body>
 
  </body>
</html>

相關(guān)文章

最新評(píng)論