表单HTML上的数据没有从javascript更改
谢谢你的快速回复。。最后我找到了函数,但我仍然不明白 这些是PHP函数:表单HTML上的数据没有从javascript更改,javascript,php,Javascript,Php,谢谢你的快速回复。。最后我找到了函数,但我仍然不明白 这些是PHP函数: $llisting =""; $ct=0; $querye = "select leavetype.id, leavetype.ltype, leaves.newbal from leavetype,leaves where username='".$_SESSION["username"]."'"; $resulte = pg_query($querye); wh
$llisting ="";
$ct=0;
$querye = "select leavetype.id, leavetype.ltype, leaves.newbal from leavetype,leaves where username='".$_SESSION["username"]."'";
$resulte = pg_query($querye);
while ($rowe = pg_fetch_array($resulte)) {
$ct=$ct+1;
$lid = $rowe[id];
$ltype = $rowe[ltype];
$newbal = $rowe[newbal];
/*$querye = "select id,ltype from leavetype order by ltype";
$resulte = pg_query($querye);
while ($rowe = pg_fetch_array($resulte)) {
$ct=$ct+1;
$lid = $rowe[id];
$ltype = $rowe[ltype];*/
$llisting=$llisting."<tr><td align=\"center\">$ct</td><td>$ltype</td><td><input type='text'>$newbal</td><td align=\"center\">";
$llisting=$llisting."<select name=\"temp$lid\" id=\"temp$lid\" class=\"span12\"><option value=\"0\"> - </option> $tlisting</select>";
$llisting=$llisting."</td></tr>\n";
//$queryn = "Update leaves set newbal='$newbal' where username='".$_SESSION["username"]."'";
//$result = pg_query($query);
}
function edit(a,b,c,d,e,f,g,h,i,j,k,l){
document.getElementById("frm").id.value=k7; document.getElementById("frm").name.value=a;
document.getElementById("frm").username.value=b;
document.getElementById("frm").emid.value=c;
document.getElementById("frm").dob.value=d;
setCheckedValue(document.forms['frm'].elements['gender'],e);
document.getElementById("frm").job.value=f;
document.getElementById("frm").info.value=g;
document.getElementById("frm").datejoin.value=h;
document.getElementById('locid').value=i;
document.getElementById('deptid').value=m m;
var myTemp = l;
var mySplitResult = myTemp.split(",");
for(i = 0; i < mySplitResult.length; i++){
cval = mySplitResult[i];
myval = cval.split("|");
val1 = myval[0];
val2 = myval[1];
document.getElementById('temp'+val1).value= val2;
}
页面将变成这样:
所以我不明白的部分是$ct、$ltype、$newbal,以及为什么编辑后所有文本字段都变成相同的值。有什么想法吗?这是一个函数,您将它们作为参数传递,因此它们来自调用此函数的位置。a..l变量是传递到函数中的参数 e、 g.
edit(myVar、anotherVar、yetAnotherVar)代码>
所有这些值都被分配给隐藏字段。首先要了解调用函数的位置,还要了解其参数这是一个函数,您要将它们作为参数传递,因此它们来自调用此函数的位置。请添加完整的代码,尝试使用jsfiddle或codepen.iohi,我已经更新了我的代码。谢谢你…请看我的代码,变量a…l是来自$name等。它们如何更改?或者它会随着顺序自动改变吗?请看我的代码,变量a…l是来自$name等。它们如何改变?还是会随着订单自动更改?
<p> </p>
<div class="box">
<div class="box-header well"><h5>Leave Information</h5></div>
<table class="table table-hover table-condensed table-bordered" >
<thead>
<tr>
<th align="center">No</th>
<th align="center">Leave Type</th>
<th align="center">Opening Balance/Entitlement</th>
<th align="center">Template</th>
</tr>
</thead>
<tbody>
[llisting]
$llisting=$llisting."<tr><td align=\"center\">$ct</td><td>$ltype</td><td><input type='text'>$newbal</td><td align=\"center\">";