|
|
|
สอบถามเรื่องการส่งค่า getElementById ไป แสดงใน checkbox ค่ะ |
|
|
|
|
|
|
|
Code (JavaScript)
if(spack_code == 'Y'){
document.getElementById("checkbox1").checked=true
}else{
document.getElementById("checkbox1").checked=false
}
|
|
|
|
|
Date :
2013-08-29 10:29:48 |
By :
Manussawin |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
วางโค๊ดดีกว่าครับ ง่ายต่อการตรวจสอบ
|
|
|
|
|
Date :
2013-08-29 11:26:54 |
By :
Ex-[S]i[L]e[N]t |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ตอบความคิดเห็นที่ : 3 เขียนโดย : Ex-[S]i[L]e[N]t เมื่อวันที่ 2013-08-29 11:26:54
รายละเอียดของการตอบ ::
ยาวนิดนึงนะคะ อันนี้หน้า popup
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head>
<script language="javascript">
function selData(intLine,plan_no,plan_delivery,supp_name,supp_code,rm_code,rm_name,trans_name,type_code,type_name,pack_code,pack_name,unit,pack_weight,car,pk_weight,weight,diff,name,deduct,wage_code,po_ref)
{
var splan_no = self.opener.document.getElementById("txtplan_no");
splan_no.value = plan_no;
var splan_delivery = self.opener.document.getElementById("txtplan_delivery");
splan_delivery.value = plan_delivery;
var ssupp_code = self.opener.document.getElementById("txtsupp_code");
ssupp_code.value = supp_code;
var ssupp_name = self.opener.document.getElementById("txtsupp_name");
ssupp_name.value = supp_name;
var srm_code = self.opener.document.getElementById("txtrm_code");
srm_code.value = rm_code;
var srm_name = self.opener.document.getElementById("txtrm_name");
srm_name.value = rm_name;
var strans_name = self.opener.document.getElementById("txttrans_name");
strans_name.value = trans_name;
var stype_code = self.opener.document.getElementById("txttype_code");
stype_code.value = type_code;
var stype_name = self.opener.document.getElementById("txttype_name");
stype_name.value = type_name;
var spack_code = self.opener.document.getElementById("txtpack_code");
spack_code.value = pack_code;
var spack_name = self.opener.document.getElementById("txtpack_name");
spack_name.value = pack_name;
var sunit = self.opener.document.getElementById("txtunit");
sunit.value = unit;
var spack_weight = self.opener.document.getElementById("txtpack_weight");
spack_weight.value = pack_weight;
var scar = self.opener.document.getElementById("txtcar");
scar.value = car;
var spk_weight = self.opener.document.getElementById("txtpk_weight");
spk_weight.value = pk_weight;
var sweight = self.opener.document.getElementById("txtweight");
sweight.value = weight;
var sdiff = self.opener.document.getElementById("txtdiff");
sdiff.value = diff;
var sname = self.opener.document.getElementById("txtn");
sname.value = name;
var sdeduct = self.opener.document.getElementById("checkbox1");
sdeduct.value = deduct;
if(sdeduct.value == "Y"){
document.getElementById("checkbox1").checked=true
}else{
document.getElementById("checkbox1").checked=false
}
var swage_code = self.opener.document.getElementById("txtw");
swage_code.value = wage_code;
var spo_ref = self.opener.document.getElementById("txtpo_ref");
spo_ref.value = po_ref;
window.close();
}
</script>
<body>
<center>
<?
$objConnect = mysql_connect("172.16.12.125","root","temp1234") or die("Error Connect to Database");
$objDB = mysql_select_db("tfm");
mysql_query("SET character_set_results=utf8");
mysql_query("SET character_set_client=utf8");
mysql_query("SET character_set_connection=utf8");
$strSQL = "SELECT plan.plan_no, plan.plan_date, plan.plan_delivery, plan.plan_user, plan.plan_remark, plan_detail.supp_name, plan_detail.supp_code, plan_detail.trans_name,plan_detail.rm_name,plan_detail.rm_code,plan_detail.type_code,plan_detail.type_name,plan_detail.pack_code,plan_detail.pack_name,plan_detail.unit,plan_detail.pack_weight,plan_detail.car,plan_detail.pack_weight,plan_detail.pk_weight,plan_detail.weight,plan_detail.diff,plan_detail.po_ref,plan_detail.wage_code,wage.name,wage.deduct FROM plan,plan_detail,wage where plan.plan_no = plan_detail.plan_no and plan_detail.wage_code = wage.code and plan.plan_delivery = '".$_POST["dateInput"]."'";
$objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]");
?>
<span class="style17">รายละเอียดการ PLAN วัตถุดิบ</span> <br>
<br>
<? include "date.php"; ?>
<br>
<table width="747" border="1" cellpadding="1" cellspacing="0">
<tr>
<th width="94" align="center" bgcolor="#336699"> <div align="center" class="style24">เลขที่เอกสาร</div></th>
<th width="85" align="center" bgcolor="#336699"> <div align="center" class="style24">วันที่สร้าง</div></th>
<th width="82" align="center" bgcolor="#336699"> <div align="center" class="style24">วันที่ส่งวัตถุดิบ</div></th>
<th width="79" align="center" bgcolor="#336699"> <div align="center" class="style24">code suppler</div></th>
<th width="123" align="center" bgcolor="#336699"> <div align="center" class="style24">ชื่อ suppler</div></th>
<th width="77" align="center" bgcolor="#336699"> <div align="center" class="style24">รหัส product</div></th>
<th width="87" align="center" bgcolor="#336699"> <div align="center" class="style24">ชื่อ product</div></th>
<th width="86" align="center" bgcolor="#336699"> <div align="center" class="style24">ชื่อ ข่นส่ง</div></th>
<th width="86" align="center" bgcolor="#336699"> <div align="center" class="style24">รัหสค่าแรง</div></th>
</tr>
<?
while($objResult = mysql_fetch_array($objQuery))
{
?>
<tr>
<td align="center" class="style9"><div align="center" class="style12 style15"><a href="#" OnClick="selData('','<?=$objResult["plan_no"];?>','<?=$objResult["plan_delivery"];?>','<?=$objResult["supp_name"];?>','<?=$objResult["supp_code"];?>','<?=$objResult["rm_code"];?>','<?=$objResult["rm_name"];?>','<?=$objResult["trans_name"];?>','<?=$objResult["type_code"];?>','<?=$objResult["type_name"];?>','<?=$objResult["pack_code"];?>','<?=$objResult["pack_name"];?>','<?=$objResult["unit"];?>','<?=$objResult["pack_weight"];?>','<?=$objResult["car"];?>','<?=$objResult["pk_weight"];?>','<?=$objResult["weight"];?>','<?=$objResult["diff"];?>','<?=$objResult["name"];?>','<?=$objResult["deduct"];?>','<?=$objResult["wage_code"];?>','<?=$objResult["po_ref"];?>');">
<?=$objResult["plan_no"];?>
</a></div></td>
<td align="center" class="style9"><span class="style16">
<?=$objResult["plan_date"];?>
</span></td>
<td align="center" class="style9"><span class="style16">
<?=$objResult["plan_delivery"];?>
</span></td>
<td align="center" class="style9"><span class="style16">
<?=$objResult["supp_code"];?>
</span></td>
<td align="center" class="style9"><span class="style16">
<?=$objResult["supp_name"];?>
</span></td>
<td align="center" class="style9"><span class="style16">
<?=$objResult["rm_code"];?>
</span></td>
<td align="center" class="style9"><span class="style16">
<?=$objResult["rm_name"];?>
</span></td>
<td align="center" class="style9"><span class="style16">
<?=$objResult["trans_name"];?>
</span></td>
<td align="center" class="style9"><span class="style16">
<?=$objResult["name"];?>
</span></td>
</tr>
<?
}
?>
</table>
<?
mysql_close($objConnect);
?>Code (PHP)
ส่วนอันนี้หน้า form รับข้อมูล
Code (PHP)
<label>
<input name="checkbox1" type="checkbox" id="checkbox1" value="Y" />
</label>
|
ประวัติการแก้ไข 2013-08-29 11:41:18 2013-08-29 11:42:49
|
|
|
|
Date :
2013-08-29 11:40:46 |
By :
supattra.s |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
จาก code นะครับ ดึงค่าจาก checkbox นะครับ ต้อง
document.getElementById("chk").checked
เช่น ในบรรทัดที่ 043
if(sdeduct.value == "Y"){...........}
แก้เป็น
if(sdeduct.checked == true){........}
หรือ if(document.getElementById("sdeduct").checked==true){........}
หวังว่าคงจะมีประโยชน์นะครับ
|
|
|
|
|
Date :
2013-08-29 17:08:10 |
By :
zoceferatu |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 02
|