 |
|
update ค่าทันทีใน form โดนไม่ต้องกด summit เป็นแบบ Onchange หรือ นับได้4อักษร แล้ว Onkeypress |
|
 |
|
|
 |
 |
|
ผมเขียนได้แนวๆนี้แต่ไม่แสดงผลอะไร
Code
<script type="text/javascript">
function culation(value,transac_id) {
document.form1.org_name_f.value = document.form1.sporg_code_f.value;
}
</script>
<%
Set rstemp = Server.CreateObject("ADODB.Recordset")
sql = "SELECT transac_id,product_name,station,used_date,liter,price_per_unit,cost,cost_center,s.cost_name,o.sporg_code,o.org_name,*FROM dbo.spemp AS e RIGHT OUTER JOIN dbo.wshell_bbl AS s ON e.spemp_code = s.spemp_id RIGHT OUTER JOIN dbo.wshell_transaction AS t ON s.card_id = t.card_id RIGHT OUTER JOIN dbo.sporg AS o ON o.sporg_code = t.cost_center WHERE s.card_type = '11' AND month(invoice_date)='"&mon_split(0)&"' AND year(invoice_date)='"&mon_split(1)&"' AND (t.remark<>'OOB' or t.remark IS NULL) AND t.card_id='"&card_id&"' ORDER BY used_date"
rstemp.cursorlocation = 3
rstemp.open sql,Conn,1,3
i=1
While Not rstemp.EOF
transac_id=rstemp(0)
sporg_code=rstemp(9)
org_name=rstemp(10)
%>
<form name="form1" action="" method="post" >
<input name="transac_id_f" type="hidden" value="<%=transac_id%>"><%=i&"."%>
<input name="sporg_code_f" type="text" value="<%=sporg_code %>" OnChange="JavaScript:culation(this.value,transac_id)">
<input name="org_name_f" type="text" value="<%=org_name%>"></form>
Tag : ASP, Ms SQL Server 2008, JavaScript
|
ประวัติการแก้ไข 2012-05-22 15:48:36 2012-05-22 16:42:37
|
 |
 |
 |
 |
Date :
2012-05-22 15:12:29 |
By :
imperator |
View :
1760 |
Reply :
6 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
<body OnLoad="document.form1.submit();">
|
 |
 |
 |
 |
Date :
2012-05-22 15:25:03 |
By :
Dragons_first |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
Code (JavaScript)
<script type="text/javascript">
function culation(value,transac_id) {
document.form1.org_name_f.value = document.form1.sporg_code_f.value;
if(document.frm.txt.value.length == 4)
{
frm.submit();
}
}
</script
แก้ไขให้ถุกด้วยครับ
|
 |
 |
 |
 |
Date :
2012-05-22 17:21:08 |
By :
mr.win |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
<script type="text/javascript">
function culation(value,transac_id) {
document.form1.org_name.value = document.form1.sporg_code.value;
if(document.form1.sporg_code.value.length == 4)
{
form1.submit();
}
}
</script>
ยังนิ่งครับ
|
 |
 |
 |
 |
Date :
2012-05-23 09:10:23 |
By :
imperator |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
Code (JavaScript)
alert(document.form1.sporg_code.value.length);
ลอง alert ดูครับ
|
 |
 |
 |
 |
Date :
2012-05-23 09:27:51 |
By :
mr.win |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ใช้กับหลายๆ record ไม่ได้อ่ะคับ เลยเปลี่ยนวิธีแล้ว
|
 |
 |
 |
 |
Date :
2012-05-24 13:50:45 |
By :
imperator |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ใช้การ OnChange แล้วส่่ง argument คำว่า this ไปครับ เราจะสามารถอ้างถึง element ปัจจุบันได้
|
 |
 |
 |
 |
Date :
2012-05-24 17:12:09 |
By :
mr.win |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|