|
![](/images/resource/spacer.gif) |
|
ขอคำชี้แนะเกี่ยวกับ การแสดงค่าบน Checkbox จากฐานข้อมูลหน่อยครับ |
|
![](/images/resource/viewboard_01.gif?v=1001) |
|
|
![](/images/resource/viewboard_03.gif?v=1001) |
![](/images/resource/viewboard_04.gif?v=1001) |
|
ผมไม่ค่อยเข้าใจน่ะครับ ปกติการเช็คค่า default ใช้แบบนี้ครับ
Code (ASP)
<input type="checkbox" name="chk1" <% IF objRec.Fields("Chk").Value="1" Then%>checked<%End IF%>>
|
![](/images/resource/blockviewtopic_01.gif?v=1001) |
![](/images/resource/blockviewtopic_02.gif?v=1001) |
![](/images/resource/blockviewtopic_03.gif?v=1001) |
![](/images/resource/blockviewtopic_04.gif?v=1001) |
Date :
2011-04-22 16:28:47 |
By :
webmaster |
|
![](/images/resource/blockviewtopic_06.gif?v=1001) |
![](/images/resource/blockviewtopic_07.gif?v=1001) |
![](/images/resource/blockviewtopic_08.gif?v=1001) |
![](/images/resource/blockviewtopic_09.gif?v=1001) |
|
|
![](/images/resource/viewboard_06.gif?v=1001) |
![](/images/resource/viewboard_07.gif?v=1001) |
|
![](/images/resource/viewboard_08.jpg?v=1001) |
![](/images/resource/viewboard_09.gif?v=1001) |
![](/images/resource/viewboard_01.gif?v=1001) |
|
|
![](/images/resource/viewboard_03.gif?v=1001) |
![](/images/resource/viewboard_04.gif?v=1001) |
|
เด๋วลองดูครับ ^^
|
![](/images/resource/blockviewtopic_01.gif?v=1001) |
![](/images/resource/blockviewtopic_02.gif?v=1001) |
![](/images/resource/blockviewtopic_03.gif?v=1001) |
![](/images/resource/blockviewtopic_04.gif?v=1001) |
Date :
2011-04-22 17:03:46 |
By :
กริ้วๆ |
|
![](/images/resource/blockviewtopic_06.gif?v=1001) |
![](/images/resource/blockviewtopic_07.gif?v=1001) |
![](/images/resource/blockviewtopic_08.gif?v=1001) |
![](/images/resource/blockviewtopic_09.gif?v=1001) |
|
|
![](/images/resource/viewboard_06.gif?v=1001) |
![](/images/resource/viewboard_07.gif?v=1001) |
|
![](/images/resource/viewboard_08.jpg?v=1001) |
![](/images/resource/viewboard_09.gif?v=1001) |
![](/images/resource/viewboard_01.gif?v=1001) |
|
|
![](/images/resource/viewboard_03.gif?v=1001) |
![](/images/resource/viewboard_04.gif?v=1001) |
|
ตอนนี้อ่านค่าจากฐานข้อมูล โดยใช้ javascript
ผมได้เพิ่ม code ในส่วนของ javascript ตอนนี้รับค่ามาโดยใช้
Code (ASP)
if ( document.all.chkrole_menu1.value = checkValues(sContact_Menu[0]))
{ document.form.chkrole_menu1.checked = true } else { document.form.chkrole_menu1.checked = false }
ผลของมันก็คือ จะ checked ให้ตลอดเลยอะครับ เลือกแถวที่ค่าไม่ตรงกันก็ checked ให้ ตลอดเลยอะครับ
ยังไงก็รบกวนชี้แนะหน่อยนะครับ
ผมพึ่งหัดเขียน asp ได้ยังไม่ถึงเดือนเลยอะครับ ช่วยๆหน่อยนะครับ![](/images/bbcode/blank.gif?v=1001)
|
![](/images/resource/blockviewtopic_01.gif?v=1001) |
![](/images/resource/blockviewtopic_02.gif?v=1001) |
![](/images/resource/blockviewtopic_03.gif?v=1001) |
![](/images/resource/blockviewtopic_04.gif?v=1001) |
Date :
2011-04-22 17:18:21 |
By :
กริ้วๆ |
|
![](/images/resource/blockviewtopic_06.gif?v=1001) |
![](/images/resource/blockviewtopic_07.gif?v=1001) |
![](/images/resource/blockviewtopic_08.gif?v=1001) |
![](/images/resource/blockviewtopic_09.gif?v=1001) |
|
|
![](/images/resource/viewboard_06.gif?v=1001) |
![](/images/resource/viewboard_07.gif?v=1001) |
|
![](/images/resource/viewboard_08.jpg?v=1001) |
![](/images/resource/viewboard_09.gif?v=1001) |
![](/images/resource/viewboard_01.gif?v=1001) |
|
|
![](/images/resource/viewboard_03.gif?v=1001) |
![](/images/resource/viewboard_04.gif?v=1001) |
|
เอา code มาเต็ม ๆ ดีกว่าครับ ![](/images/bbcode/grin.gif?v=1001)
|
![](/images/resource/blockviewtopic_01.gif?v=1001) |
![](/images/resource/blockviewtopic_02.gif?v=1001) |
![](/images/resource/blockviewtopic_03.gif?v=1001) |
![](/images/resource/blockviewtopic_04.gif?v=1001) |
Date :
2011-04-22 17:22:05 |
By :
webmaster |
|
![](/images/resource/blockviewtopic_06.gif?v=1001) |
![](/images/resource/blockviewtopic_07.gif?v=1001) |
![](/images/resource/blockviewtopic_08.gif?v=1001) |
![](/images/resource/blockviewtopic_09.gif?v=1001) |
|
|
![](/images/resource/viewboard_06.gif?v=1001) |
![](/images/resource/viewboard_07.gif?v=1001) |
|
![](/images/resource/viewboard_08.jpg?v=1001) |
![](/images/resource/viewboard_09.gif?v=1001) |
![](/images/resource/viewboard_01.gif?v=1001) |
|
|
![](/images/resource/viewboard_03.gif?v=1001) |
![](/images/resource/viewboard_04.gif?v=1001) |
|
Code (ASP)
<%OPTION EXPLICIT%>
<!--#INCLUDE FILE="chsession.inc"-->
<%
Dim User_role_id, lbtitle
User_role_id = ""
if not isEmpty(Request("User_role_id")) then
User_role_id = Request("User_role_id")
lbtitle = "Edit Role Menu"
else
lbtitle = "New Page"
end if
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<HEAD>
<TITLE> Osotspa </TITLE>
<META NAME="Generator" CONTENT="EditPlus">
<META NAME="Author" CONTENT="">
<META NAME="Keywords" CONTENT="">
<META NAME="Description" CONTENT="">
<link href="css/css.css" rel="stylesheet" type="text/css" />
<script src="include/CalendarControl.js" language="javascript"></script>
<link href="include/CalendarControl.css" rel="stylesheet" type="text/css">
<script language="javascript" src="Include/jsf.js"></script>
</HEAD>
<body>
<table align="center" width="750" border="0" cellpadding="0" cellspacing="0">
<tr>
<td height="25" bgcolor="#FF339A" style="padding-left:20px;" colspan="2" class="txt_w" >
<font color="#FFFFFF" >
<u> Manage Users : Role</u> </font>
<a id="tt" href="javascript:;"></a>
</td>
</tr>
<tr>
<td height="10" class="txt_s" align="left" style="padding-left:20px;" bgcolor="#FF339A" >
</td>
</tr>
<tr>
<td height="10" class="txt_s" align="left" style="padding-left:20px;" bgcolor="#FFFFFF" >
</td>
</tr>
<tr>
<td align="left" style="padding-left:10px;" >
<form name="form" method="post" action="action/act_ap_role.asp">
<table align="center" cellpadding="0" cellspacing="0" width="80%" border="0" >
<tr>
<td height="30" align="left" style="padding-left:5px;">
<img src="image/bull_pink16x16.gif" align="absmiddle">
<b><%= lbtitle%></b>
</td>
<td height="30" align="right" style="padding-right:5px;">
<a href="Javascript:profileList();">
<img src="image/bull_pink16x16.gif" align="absmiddle" border="none">List
</a>
<a href="Javascript:newProfile();">
<img src="image/bull_pink16x16.gif" align="absmiddle" border="none">Add New
</a>
</td>
</tr>
<tr>
<td height="15">
</td>
</tr>
<input type="hidden" name="User_role_id" size="30" class="inpTxt" value="<%=User_role_id%>">
<tr>
<td align="left" style="padding-left:10px;" height="25" class="sa">
<b>Role Menu :</b>
</td>
</tr>
<tr>
<td align="left" style="padding-left:10px;" class="sa" width="20%"> </td>
<td align = "left" >
<input type="checkbox" name="chkrole_menu1"> <font color="#003300" value = "Contact_Menu" class="chkbox" >
<b>Contact Menu</b> </font>
</td>
</tr>
<tr>
<td align="left" style="padding-left:10px;" class="sa" width="20%"> </td>
<td align = "left" >
<input type="checkbox" name="chkrole_menu2"> <font color="#003300" value = "Complaint_Menu" class="chkbox" >
<b>Complaint Menu</b> </font>
</td>
</tr>
<tr>
<td align="left" style="padding-left:10px;" class="sa" width="20%"> </td>
<td align = "left" >
<input type="checkbox" name="chkrole_menu3"> <font color="#003300" value = "knowledge_Menu" class="chkbox" >
<b>knowledge Menu</b> </font>
</td>
</tr>
<tr>
<td align="left" style="padding-left:10px;" class="sa" width="20%"> </td>
<td align = "left" >
<input type="checkbox" name="chkrole_menu4"> <font color="#003300" value = "Report_Menu" class="chkbox" >
<b>Report Menu</b> </font>
</td>
</tr>
<tr>
<td align="left" style="padding-left:10px;" class="sa" width="20%"> </td>
<td align = "left" >
<input type="checkbox" name="chkrole_menu5"> <font color="#003300" value = "Admin_Menu" class="chkbox" >
<b>Admin Menu</b> </font>
</td>
</tr>
<tr>
<td align="left" style="padding-left:10px;" class="sa" width="20%"> </td>
<td align = "left" >
<input type="checkbox" name="chkrole_menu6"> <font color="#003300" value = "Help_Menu" class="chkbox" >
<b>Help Menu</b> </font>
</td>
</tr>
<tr><td height="10"></td></tr>
<tr>
<td align="center" height="25" colspan="2" class="sa1">
<a href="Javascript:act(1);"><img src="image/accept-15x15.png" border="0" align="absmiddle"/> Save</a>
<a href="Javascript:act(2);"><img src="image/refresh-15x15.png" border="0" align="absmiddle"/> Cancel</a>
</td>
</tr>
<tr><td height="10"></td></tr>
</table>
</form><!--End Form Search-->
</td>
</tr>
</table>
<script language="javascript">
function loadXML() {
var User_role_id = document.all.User_role_id.value
var chkrole_menu1 = document.all.chkrole_menu1.value
var chkrole_menu2 = document.all.chkrole_menu2.value
var check = "Y"
var uncheck = "N"
var temp = ""
var url = "xml/xml_ap_role_menu.asp?User_role_id="+User_role_id
var srchXML = new ActiveXObject ("MSXML.DOMDocument");
srchXML.async = false;
srchXML.load(url);
var srchData = srchXML.getElementsByTagName("items");
if (srchData.length > 0) {
var sUser_role_id= srchXML.getElementsByTagName("User_role_id");
var sContact_Menu= srchXML.getElementsByTagName("Contact_Menu");
var sComplaint_Menu= srchXML.getElementsByTagName("Complaint_Menu");
alert(checkValues(sContact_Menu[0]))
alert(document.all.chkrole_menu1.value)
if ( document.all.chkrole_menu1.value = checkValues(sContact_Menu[0]))
{ document.form.chkrole_menu1.checked = true } else { document.form.chkrole_menu1.checked = false }
if ( document.all.chkrole_menu2.value != checkValues(sComplaint_Menu[0]))
{ document.form.chkrole_menu2.checked = false
}
}
alert(document.all.chkrole_menu1.value)
}
loadXML()
function newProfile() {
var url = 'ap_role.asp'
window.open(url, '_self')
}
function profileList() {
var url = 'ap_role_list.asp'
window.open(url, '_self')
}
//-----------------------------------------------------BUTTON SAVE-------------------------------------------------------------//
function act(opt) {
//var user_type = document.all.user_type.value
if(opt == 1) {
//if(user_type == ""){
//alert("กรุณาระบุประเภทผู้ใช้งาน !!")
//}else{
document.all.form.submit()
//}
}else if(opt == 2) {
document.all.form.reset()
}
}
//-----------------------------------------------------BUTTON SAVE-------------------------------------------------------------//
</script>
</body>
</html>
แฮะๆ
|
![](/images/resource/blockviewtopic_01.gif?v=1001) |
![](/images/resource/blockviewtopic_02.gif?v=1001) |
![](/images/resource/blockviewtopic_03.gif?v=1001) |
![](/images/resource/blockviewtopic_04.gif?v=1001) |
Date :
2011-04-22 17:28:18 |
By :
กริ้วๆ |
|
![](/images/resource/blockviewtopic_06.gif?v=1001) |
![](/images/resource/blockviewtopic_07.gif?v=1001) |
![](/images/resource/blockviewtopic_08.gif?v=1001) |
![](/images/resource/blockviewtopic_09.gif?v=1001) |
|
|
![](/images/resource/viewboard_06.gif?v=1001) |
![](/images/resource/viewboard_07.gif?v=1001) |
|
![](/images/resource/viewboard_08.jpg?v=1001) |
![](/images/resource/viewboard_09.gif?v=1001) |
|
|
|
![](/images/digitalocean-banner.jpg)
|
Load balance : Server 02
|