****我有五个小问题,帮帮忙啦****

ssh78 2003-10-23 10:58:14

有一个table(1行3列),每个单元格里都有文本框,用户在第一个格里输入值,然后按回车键,那么就要执行一个javascript function。这个fuction要执行三个动作。
1 判断用户是否按下了回车键,如果按下,就执行2和3。
2 取这个文本框的值,到数据库中再查询纪录(当然结果肯定只有一条)。
3 将查询结果的一个字段值填充到同一行的第二个文本框里。
4 焦点定位在同一行的第三个文本框里。
5 在table里再生成新的一行,并且新的一行也能进行同样的操作。
请问这个js fuction怎么写?
...全文
66 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
xuzuning 2003-10-23
  • 打赏
  • 举报
回复
<table id="tab" onkeydown="keycheck()">
<tr>
<td><input></td>
<td><input></td>
<td><input></td>
</tr>
</table>

<script id="server" src="" onreadystatechange="server_return()"></script>

<script>
function keycheck() {
el = event.srcElement;
if(event.keyCode == 13) {
if(el.parentElement.cellIndex == 0)
server.src = "服务器程序?k="+el.value; // 见要求
}
}
server_mode = "";
function server_return() {
if(server_mode == "") return;
el.parentElement.parentElement.cells[1].children[0].value = server_mode;
el.parentElement.parentElement.cells[2].children[0].focus();

row = tab.lastChild.appendChild(tab.rows(tab.rows.length-1).cloneNode(true))
for(i=0;i<row.cells.length;i++)
row.cells[i].children[0].value = "";
}
</script>

要求:
服务器程序可以是任意语言,只要能做到:
接受url参数,处理完毕后输出一行
server_mode = "这里是查询结果";
黑马 2003-10-23
  • 打赏
  • 举报
回复
4、用focus即可
5、见 http://expert.csdn.net/Expert/TopicView1.asp?id=2377985
JK_10000 2003-10-23
  • 打赏
  • 举报
回复
<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">

<title>GetInfoFromDataBase</title>
</head>
<script>

function addFun()//JK
{
var newRow = forAddTable.rows[0].cloneNode(true);
var desRow = scoreTable.rows[scoreTable.rows.length-1];
desRow.parentElement.insertBefore(newRow,desRow);
scoreTable.rows[scoreTable.rows.length-2].all.studentNo.focus();
}
function deleteFun(deleteButton)//JK
{

var documentCheckBox=document.getElementsByName("scoreID");
if (confirm("Are you sure to delete?"))
{
scoreTable.deleteRow(deleteButton.parentElement.parentElement.rowIndex);
}

}

function getTheStudentNameFun(studentNoInput)
{
var a=showModalDialog("GetStudentByNo.jsp?studentNo="+studentNoInput.value,"","status:no;resizable:no;help:no;dialogHeight:10px;dialogWidth:10px;");
//if (a!=null)
{
studentNoInput.parentElement.parentElement.all.studentName.value=a;
}


}

function keyDownControl()
{
k=event.keyCode;
if(k==13)
{
event.keyCode=9;
}

}
</script>
<body>

<table width="100%" cellspacing="1" cellpadding="2" align="left" id="scoreTable">

<tr >
<td width=1 > </td>
<td >No</td>
<td >Name</td>
<td >Score</td>
</tr>

<tr >
<td width=1 ><input type=button value=Delete onclick="deleteFun(this);" ></td>
<td ><input name=studentNo onchange="getTheStudentNameFun(this);return ;" onkeydown="keyDownControl();"></td>
<td ><input name=studentName disabled></td>
<td ><input name=studentScore onkeydown="keyDownControl();"></td>
</tr>
<tr><td><input type=button value=Add onclick="addFun();" ></td></tr>
</table>


<table id=forAddTable disabled style="display:none">
<tr >
<td width=1 ><input type=button value=Delete onclick="deleteFun(this);" ></td>
<td ><input name=studentNo onchange="getTheStudentNameFun(this);return ;" onkeydown="keyDownControl();"></td>
<td ><input name=studentName disabled></td>
<td ><input name=studentScore onkeydown="keyDownControl();"></td>
</tr>
</table>

</body>

</html>


-------------------------------------
GetStudentByNo.jsp:


<%String theStudentName="独孤求败";%>

<
script language=javascript>

window.returnValue='<%=theStudentName%>';
window.close();
</script>
JK_10000 2003-10-23
  • 打赏
  • 举报
回复
<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">

<title>GetInfoFromDataBase</title>
</head>
<script>

function addFun()//JK
{
var newRow = forAddTable.rows[0].cloneNode(true);
var desRow = scoreTable.rows[scoreTable.rows.length-1];
desRow.parentElement.insertBefore(newRow,desRow);
scoreTable.rows[scoreTable.rows.length-2].all.studentNo.focus();
}
function deleteFun(deleteButton)//JK
{

var documentCheckBox=document.getElementsByName("scoreID");
if (confirm("Are you sure to delete?"))
{
scoreTable.deleteRow(deleteButton.parentElement.parentElement.rowIndex);
}

}

function getTheStudentNameFun(studentNoInput)
{
var a=showModalDialog("GetStudentByNo.jsp?studentNo="+studentNoInput.value,"","status:no;resizable:no;help:no;dialogHeight:10px;dialogWidth:10px;");
//if (a!=null)
{
studentNoInput.parentElement.parentElement.all.studentName.value=a;
}


}

function keyDownControl()
{
k=event.keyCode;
if(k==13)
{
event.keyCode=9;
}

}
</script>
<body>

<table width="100%" cellspacing="1" cellpadding="2" align="left" id="scoreTable">

<tr >
<td width=1 > </td>
<td >No</td>
<td >Name</td>
<td >Score</td>
</tr>

<tr >
<td width=1 ><input type=button value=Delete onclick="deleteFun(this);" ></td>
<td ><input name=studentNo onchange="getTheStudentNameFun(this);return ;" onkeydown="keyDownControl();"></td>
<td ><input name=studentName disabled></td>
<td ><input name=studentScore onkeydown="keyDownControl();"></td>
</tr>
<tr><td><input type=button value=Add onclick="addFun();" ></td></tr>
</table>


<table id=forAddTable disabled style="display:none">
<tr >
<td width=1 ><input type=button value=Delete onclick="deleteFun(this);" ></td>
<td ><input name=studentNo onchange="getTheStudentNameFun(this);return ;" onkeydown="keyDownControl();"></td>
<td ><input name=studentName disabled></td>
<td ><input name=studentScore onkeydown="keyDownControl();"></td>
</tr>
</table>


-------------------------------------
GetStudentByNo.jsp:


<%String theStudentName="独孤求败";%>

<
script language=javascript>

window.returnValue='<%=theStudentName%>';
window.close();
</script>

</body>

</html>

内容概要:本文系统介绍了用于变分自动编码器(VAE)的Copula变分贝叶斯算法的Matlab代码实现,重点在于融合Copula函数以增强VAE对复杂数据依赖结构的建模能力。内容涵盖算法的理论基础、概率图模型构建、变分推断过程及Copula函数在隐变量分布建模中的集成方法,并提供了完整的代码实现流程,便于读者复现与应用。文档还列举了包括智能优化、机器学习、电力系统、信号处理在内的多项科研方向,突出该方法在多学科交叉研究中的广泛应用潜力,尤其适用于需精确刻画变量间非线性依赖关系的高级建模任务。; 适合人群:具备扎实的数学基础与机器学习理论知识,熟悉概率图模型与变分推断方法,且有一定Matlab编程经验的研究生、博士生及科研人员,特别适合从事VAE改进、贝叶斯深度学习、新能源系统不确定性建模及相关领域研究的学者。; 使用场景及目标:①深入理解Copula函数如何提升VAE在复杂数据结构下的表达能力,特别是在非高斯隐空间建模中的作用;②掌握基于Matlab实现Copula增强型VAE的具体编程技巧与调试方法;③复现博士论文核心技术,支撑高水平科研成果产出,如期刊投稿、学位论文撰写及工程原型开发。; 阅读建议:此资源不仅适用于算法学习与代码实践,更应结合具体科研问题进行拓展研究。建议读者按照文档结构循序渐进地学习,重点关注Copula建模与变分下界优化之间的数学推导与代码映射关系,并尝试在不同数据集(如金融时间序列、能源负荷数据)上验证模型性能,以深化理解并激发创新性研究思路。

87,987

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧