关于表格的问题 在jsp页面里设置一张表最开开始的时候显示一行空的在假设你输入就敲回车显示下一行这样怎么写最好给个实例. 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 <table id="testTable" border="1"><tr><td> </td></tr></table><input type="button" value="Add" onclick="addRow()"/><script>function addRow() {var table = document.getElementById("testTable");var tbody = table.tBodies[0];var tr = document.createElement("TR");var td = document.createElement("TD");td.innerHTML = "新行";tr.appendChild(td);tbody.appendChild(tr);table.appendChild(tbody);}</script> 这样Add的TEXT的值都是"新行"了我想要的就是可以在text框可输入的一行4个在一个怎么去接收他的值.. <table id="testTable" border="1"><tr><td> </td></tr></table><input type="button" value="Add" onclick="addRow()"/><input type="button" value="Get Value" onclick="getValue()"/><script>var textIndex = 0;function addRow() {var table = document.getElementById("testTable");var tbody = table.tBodies[0];var tr = document.createElement("TR");var td = document.createElement("TD");var input = document.createElement("INPUT");input.type="text";input.id="testInput" + textIndex;td.appendChild(input);tr.appendChild(td);textIndex++;td = document.createElement("TD");input = document.createElement("INPUT");input.type="text";input.id="testInput" + textIndex;td.appendChild(input);tr.appendChild(td);textIndex++;td = document.createElement("TD");input = document.createElement("INPUT");input.type="text";input.id="testInput" + textIndex;td.appendChild(input);tr.appendChild(td);textIndex++;td = document.createElement("TD");input = document.createElement("INPUT");input.type="text";input.id="testInput" + textIndex;td.appendChild(input);tr.appendChild(td);textIndex++;tbody.appendChild(tr);table.appendChild(tbody);}function getValue() {for(var i = 0; i < textIndex; i++) {var text = document.getElementById("testInput" + i);alert(text.value);}}</script> 兄弟帮忙帮到底 真是急 最好能不能不用ADD!直接用回车键! 那个接收值给个变量接收就好了,要get vlaue 因为值之后是要存到数据库去的 帮下我谢了 把ADD的事件,放在回车按钮上就好啦^_^ 回车是指在text文本框里回车就生成第二行值是怎么在JSP页码取(就是每一行的4个TEXT文本框的值!!!之后是把这一行的值存在数据库做一条记录..) <table id="testTable" border="1"> <tr id="testTr0"> <td><input type="text" id="testInput0" value="" onkeydown="addRow('1')"/></td> <td><input type="text" id="testInput1" value="" onkeydown="addRow('1')"/></td> <td><input type="text" id="testInput2" value="" onkeydown="addRow('1')"/></td> <td><input type="text" id="testInput3" value="" onkeydown="addRow('1')"/></td> </tr></table>获得第<input type="text" id="getRowValueIndex" value=""/>行的值<input type="button" value="Get Value" onclick="getValue()"/><script> var textIndex = 4; var rowIndex = 1; function addRow(newRowIndex) { if (event.keyCode == 13 && newRowIndex == rowIndex) { var table = document.getElementById("testTable"); var tbody = table.tBodies[0]; var tr = document.createElement("TR"); tr.id="testTr" + rowIndex; rowIndex++; var td; var input; for (var i = 0; i < 4; i++) { td = document.createElement("TD"); input = document.createElement("INPUT"); input.type="text"; input.id="testInput" + textIndex; input.onkeydown = function () {addRow(rowIndex);}; td.appendChild(input); tr.appendChild(td); textIndex++; } tbody.appendChild(tr); table.appendChild(tbody); } } function getValue() { var getRowValueIndex = document.getElementById("getRowValueIndex"); var startInputIndex = getRowValueIndex.value * 4 - 4; var endInputIndex = getRowValueIndex.value * 4; if (getRowValueIndex.value != "") { var input1 = document.getElementById("testInput" + (getRowValueIndex.value * 4 - 4)).value; var input2 = document.getElementById("testInput" + (getRowValueIndex.value * 4 - 3)).value; var input3 = document.getElementById("testInput" + (getRowValueIndex.value * 4 - 2)).value; var input4 = document.getElementById("testInput" + (getRowValueIndex.value * 4 - 1)).value; alert("第 " + getRowValueIndex.value + " 行,第1个文本框的值为:" + input1 + ";第2个文本框的值为:" + input2 + ";第3个文本框的值为:" + input3 + ";第4个文本框的值为:" + input4); } }</script> 怎么实现 图片上传预览 关于response的文档 关于jprofiler在unix中连接问题 用SSH做项目,当数据量大的时候如何优化? jspSmartUpload可不可以检测目录下是否已存在相同的文件? JBuilder9.0怎们用 初学jsp,在线等(装上tomcat5.5后的问题) 在线等:在servlet中使用getAttribute()时出错!!! 我想请教各位大虾几个问题!!输入数据库时单引号问题是如何解决的??还有如何控制突发事件?? 关于tomcat的问题(高分) 关于Java Mail的奇怪问题 关于jsp中cookie储存session号的问题
<table id="testTable" border="1">
<tr><td> </td></tr>
</table>
<input type="button" value="Add" onclick="addRow()"/><script>
function addRow() {
var table = document.getElementById("testTable");
var tbody = table.tBodies[0];
var tr = document.createElement("TR");
var td = document.createElement("TD");
td.innerHTML = "新行";
tr.appendChild(td);
tbody.appendChild(tr);
table.appendChild(tbody);
}
</script>
我想要的就是可以在text框可输入的
一行4个
在一个怎么去接收他的值..
<table id="testTable" border="1">
<tr><td> </td></tr>
</table>
<input type="button" value="Add" onclick="addRow()"/>
<input type="button" value="Get Value" onclick="getValue()"/><script>
var textIndex = 0;
function addRow() {
var table = document.getElementById("testTable");
var tbody = table.tBodies[0];
var tr = document.createElement("TR");var td = document.createElement("TD");
var input = document.createElement("INPUT");
input.type="text";
input.id="testInput" + textIndex;
td.appendChild(input);
tr.appendChild(td);
textIndex++;td = document.createElement("TD");
input = document.createElement("INPUT");
input.type="text";
input.id="testInput" + textIndex;
td.appendChild(input);
tr.appendChild(td);
textIndex++;td = document.createElement("TD");
input = document.createElement("INPUT");
input.type="text";
input.id="testInput" + textIndex;
td.appendChild(input);
tr.appendChild(td);
textIndex++;td = document.createElement("TD");
input = document.createElement("INPUT");
input.type="text";
input.id="testInput" + textIndex;
td.appendChild(input);
tr.appendChild(td);
textIndex++;tbody.appendChild(tr);
table.appendChild(tbody);
}function getValue() {
for(var i = 0; i < textIndex; i++) {
var text = document.getElementById("testInput" + i);
alert(text.value);
}
}
</script>
最好能不能不用ADD!直接用回车键!
那个接收值给个变量接收就好了,要get vlaue 因为值之后是要存到数据库去的
帮下我谢了
把ADD的事件,放在回车按钮上就好啦^_^
值是怎么在JSP页码取(就是每一行的4个TEXT文本框的值!!!之后是把这一行的值存在数据库做一条记录..)
<table id="testTable" border="1">
<tr id="testTr0">
<td><input type="text" id="testInput0" value="" onkeydown="addRow('1')"/></td>
<td><input type="text" id="testInput1" value="" onkeydown="addRow('1')"/></td>
<td><input type="text" id="testInput2" value="" onkeydown="addRow('1')"/></td>
<td><input type="text" id="testInput3" value="" onkeydown="addRow('1')"/></td>
</tr>
</table>获得第<input type="text" id="getRowValueIndex" value=""/>行的值
<input type="button" value="Get Value" onclick="getValue()"/><script>
var textIndex = 4;
var rowIndex = 1;
function addRow(newRowIndex) {
if (event.keyCode == 13 && newRowIndex == rowIndex) {
var table = document.getElementById("testTable");
var tbody = table.tBodies[0];
var tr = document.createElement("TR");
tr.id="testTr" + rowIndex;
rowIndex++; var td;
var input;
for (var i = 0; i < 4; i++) {
td = document.createElement("TD");
input = document.createElement("INPUT");
input.type="text";
input.id="testInput" + textIndex;
input.onkeydown = function () {addRow(rowIndex);};
td.appendChild(input);
tr.appendChild(td);
textIndex++;
}
tbody.appendChild(tr);
table.appendChild(tbody);
}
}
function getValue() {
var getRowValueIndex = document.getElementById("getRowValueIndex");
var startInputIndex = getRowValueIndex.value * 4 - 4;
var endInputIndex = getRowValueIndex.value * 4;
if (getRowValueIndex.value != "") {
var input1 = document.getElementById("testInput" + (getRowValueIndex.value * 4 - 4)).value;
var input2 = document.getElementById("testInput" + (getRowValueIndex.value * 4 - 3)).value;
var input3 = document.getElementById("testInput" + (getRowValueIndex.value * 4 - 2)).value;
var input4 = document.getElementById("testInput" + (getRowValueIndex.value * 4 - 1)).value;
alert("第 " + getRowValueIndex.value + " 行,第1个文本框的值为:" + input1 + ";第2个文本框的值为:" + input2 + ";第3个文本框的值为:" + input3 + ";第4个文本框的值为:" + input4);
}
}
</script>