Sat 26 Jul 2008 15:21:36
code
<html>
<head>
<script>
function edit_comment(p) {
input_label = "inputtime"+p
com_label = "comment"+p
com_value = "ot_com"+p ;
c_label = document.getElementById(com_label) ;
c_value = document.getElementById(com_value) ;
old_value = c_value.value ;
mText = "<textarea name='"+input_label+"' onclick='dbl_com("+p+")' onSelect='select_time("+p+")' onBlur='save_com("+p+")' style='width:200;'>"+old_value+" </textarea>" ;
// mText = "<input type='text' name='"+input_label+"' value='"+old_value+"' onclick='dbl_com("+p+")' onSelect='select_time("+p+")' onBlur='save_com("+p+")' style='width:100;'>" ;
c_label.innerHTML = mText ;
document.getElementById(input_label).focus() ;
}
function dbl_com(p) {
input_label = "inputtime"+p
save_com(p) ;
// document.getElementById(input_label).focus() ;
}
function save_com(p) {
input_label = "inputtime"+p
com_label = "comment"+p
com_value = "ot_com"+p ;
c_label = document.getElementById(com_label) ;
c_value = document.getElementById(com_value) ;
edt_value = document.getElementById(input_label).value ;
c_label.innerHTML = edt_value ;
c_value.value = edt_value ;
}
</script>
</head>
<body>
<%
i=1
response.write "<input type='hidden' name='ot_com"&i&"' value=''>"
%>
<table width="62%" border="1" align="center" style="border-collapse: collapse;">
<tr bgcolor="#CCCCCC">
<td nowrap><div id = "comment<%=i%>" onClick="edit_comment(<%=i%>)" style="width:100; cursor: hand;"> </div></tr></td>
</body>
</html>
หาก จะเปลียน จาก textrea เป็น select option จะแก้ยังไงครับ
รบกวนผู้รู้หน่อยครับ ขอบคุณมากครับ
Sat 26 Jul 2008 15:23:11
savd เป็นasp นะครับถึงรันได้
Sat 26 Jul 2008 15:30:25
mText = "<select name='"+input_label+"' onclick='dbl_com("+p+")' onSelect='select_time("+p+")' onBlur='save_com("+p+")' style='width:200;'>"+old_value+" <option>a<option>b<option>c</select>" ;
ลองแก้เป็น select แต่ค่า มันไม่เก็บในตารางให้ครับ ช่วยด้วยครับ
Sat 26 Jul 2008 20:59:20
Mon 28 Jul 2008 08:32:54
ลองใช้ event onchange ดู แล้วครับ แต่ว่า พอคลิกที่ option ตัวไหม่มันก็ไม่เปลี่ยน แล้ว พอคลิก ให้มันเก็บในตารางมันก็ไม่เก็บค่าครับ รบกวนผู้รู้ช่วยหน่อยครับ
Mon 28 Jul 2008 12:44:31
ลอง detect ง่ายๆโดยใน function save_com ให้ใส่ alert(p); เข้าไป จะให้ดีก็ใช้ firefox และ opera ในการหาจุดผิดพลาด
Tue 29 Jul 2008 17:10:32
ลองจริงๆมีครับ <option> มี </option> แต่ มันเหมือนกับ object select option มันไม่ทำงานครับ หาก เขียน บน javascript อย่างเดี่ยว โดยไม่ได้ดึงมาจาก form ครับ เพราะ ผมลอง คลิก ค่าใน option ไม่ยอมเปลี่ยนต่างจาก สร้างใน form ครับ รบกวนผู้รู้ ผู้เชี่ยวชาญ แนะนำ หน่อยครับ หากเป็นไปได้ อยากให้ลอง run code ที่ โพส์ไว้ ครับ และ หาก แก้ได้ รบกวน post code ที่แก้ให้ด้วยครับ ขอบคุณมาก ครับ
Wed 30 Jul 2008 01:22:54

















