|
|
|
ช่วยแนะนำทีครับ เกี่ยวกับ select checkbox all และการ show/hide textbox ครับ |
|
|
|
|
|
|
|
ต้องดูที่เงื่อนไขของฟังก์ชันครับ
ลองเอาโค้ดมาแปะดูครับ
|
|
|
|
|
Date :
2012-03-29 14:30:18 |
By :
50121680 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Code (PHP)
<!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>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>: : Preventive & Maintenance Node : :</title>
<script language="javascript">
function fncShowHideInput(value) {
var input1 = document.getElementById('v_AC');
if(value.checked) {input1.style.display='';}
else{input1.style.display='none';}
}
//////////////////////////
function fncShowHideInput2(value2) {
var input2 = document.getElementById('v_DC');
if(value2.checked) {input2.style.display='';}
else{input2.style.display='none';}
}
/////////////////////////
function fncShowHideInput3(value3) {
var input3 = document.getElementById('batt');
if(value3.checked) {input3.style.display='';}
else{input3.style.display='none';}
}
</script>
<script language = "JavaScript">
function Listnode(SelectValue)
{
form1.node.length = 0
<?
$intRows = 0;
$strSQLm = "SELECT * FROM pm ORDER BY node_H ASC";
$objQuerym = mysql_query($strSQLm) or die ("Error Query [".$strSQLm."]");
$intRows = 0;
while($objResultm = mysql_fetch_array($objQuerym))
{
$intRows++;
?>
x = <?=$intRows;?>;
mySubList = new Array();
strGroup = <?=$objResultm["id"];?>;
strValue = "<?=$objResultm["location"];?>";
strItem = "<?=$objResultm["location"];?>";
mySubList[x,0] = strItem;
mySubList[x,1] = strGroup;
mySubList[x,2] = strValue;
if (mySubList[x,1] == SelectValue){
var myOption = new Option(mySubList[x,0], mySubList[x,2])
form1.node.options[form1.node.length]= myOption
}
<?
}
?>
}
</script>
<link rel="stylesheet" type="text/css" href="../../Scripts/epoch_styles.css"/>
<script type="text/javascript" src="../../Scripts/epoch_classes.js">//***Calendar****//</script>
<script type="text/javascript">
var calendar;
window.onload = function() {
calendar = new Epoch('cal2','popup',document.getElementById('calendar_container'),false);
};
//***end Calendar***//
</script>
<script language=JavaScript type=text/javascript>
<!--
function CheckAll() {
for (var i = 0; i < document.form1.elements.length; i++) {
if(document.form1.elements[i].type == 'checkbox'){
document.form1.elements[i].checked = !(document.form1.elements[i].checked);
}
}
}
//-->
</script>
<style type="text/css">
<!--
.style12 {font-size: 12px; font-weight: bold; color: #666666; }
.style2 {font-weight: bold; font-size: 24px;}
.style13 {font-size: 12px}
.style14 {color: #FFFFFF}
.style15 {font-size: 14px}
.style19 {color: #FFFFFF; font-weight: bold; font-size: 12px; }
.style20 {color: #999999}
.style21 {font-weight: bold; font-size: 36px; }
a:link {
color: #FFFFFF;
text-decoration: none;
}
a:visited {
text-decoration: none;
color: #FFFFFF;
}
a:hover {
text-decoration: none;
color: #00FF00;
}
a:active {
text-decoration: none;
}
-->
</style>
</head>
<body>
<script language="javascript">
function fncSubmit()
{
if(document.form1.date.value == "")
{
alert('กรุณาใส่วันที่');
document.form1.date.focus();
return false;
}
if(document.form1.location.value == "")
{
alert('กรุณาเลือก Location ');
document.form1.location.focus();
return false;
}
if(document.form1.node.value == "")
{
alert('กรุณาเลือก node');
document.form1.node.focus();
return false;
}
document.form1.submit();
}
</script>
<form id="form1" name="form1" method="post" action="savePM.php" OnSubmit="return fncSubmit();">
<table width="613" border="0" align="center" cellpadding="3" cellspacing="1" bgcolor="#333333">
<tr>
<td width="50"> </td>
<td width="170" align="right"><span class="style19">ID</span></td>
<td width="170"><input name="UserID" type="text" id="UserID" value="<?php echo $objResult['UserID'];?>" size="7" readonly="true" autocomplete="off"/></td>
<td width="50"> </td>
</tr>
<tr>
<td> </td>
<td align="right"><span class="style19">วันที่</span></td>
<td><input type="text" name="date" id="calendar_container" style="width:80px" autocomplete="off" /></td>
<td> </td>
</tr>
<tr>
<td> </td>
<td align="right"><span class="style1"><span class="style19">Locations</span></span></td>
<td><span class="style1">
<select id="location" name="location" style="width:170px" onchange="Listnode(this.value)">
<option selected="selected" value=""></option>
<?php
$strSQLm = "SELECT * FROM pm ORDER BY node_H";
$objQuerym = mysql_query($strSQLm)or die("Error Query [".$strSQLm."]");
while($objResultm = mysql_fetch_array($objQuerym))
{
?>
<option value="<?=$objResultm["id"];?>">
<?=$objResultm["node_H"];?>
|
<?=$objResultm["location"];?>
</option>
<?
}
?>
</select>
</span></td>
<td> </td>
</tr>
<tr>
<td> </td>
<td align="right"><span class="style19">Node Name</span></td>
<td><select name="node" id="node" style="width:170px">
</select></td>
<td> </td>
</tr>
<tr>
<td><label></label></td>
<td align="right"><span class="style19">ผู้ปฏิบัติงาน 1</span></td>
<td><input name="worker1" type="text" id="worker1" style="width:170px" value="<?php echo $objResult["fname"];?>" readonly="true" /></td>
<td> </td>
</tr>
<tr>
<td> </td>
<td align="right"><span class="style19">ผู้ปฏิบัติงาน 2</span></td>
<td><select name="worker2" id="worker2" style="width:170px">
<option selected="selected"></option>
<?
$mem2SQL = "SELECT fname FROM members";
$mem2Query = mysql_query($mem2SQL);
while($mem2Result = mysql_fetch_array($mem2Query))
{
?>
<option value="<?=$mem2Result["fname"];?>">
<?=$mem2Result["fname"];?>
</option>
<?
}
?>
</select></td>
<td> </td>
</tr>
<tr>
<td colspan="4" bgcolor="#FFFFFF"> </td>
</tr>
<tr>
<td> </td>
<td bgcolor="#FF0000"><input type="button" name="Button" value="Select All" onClick=CheckAll();></td>
<td bgcolor="#FF0000"> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td bgcolor="#FF0000"><span class="style8 style14 style15"><strong>ระบบ Power</strong></span></td>
<td bgcolor="#FF0000"><span class="style8 style14 style15"><strong>ระบบระบายอากาศ</strong></span></td>
<td> </td>
</tr>
<tr>
<td> </td>
<td bgcolor="#CCCCCC"><span class="style3 style13"><strong>
<label>
<input name="power1" type="checkbox" id="power1" value="1" />
meter main AC </label>
</strong></span></td>
<td bgcolor="#CCCCCC"><span class="style13 style3"><strong>
<label>
<input name="Air1" type="checkbox" id="Air1" value="1" />
พัดลมฝาตู้ </label>
</strong></span></td>
<td> </td>
</tr>
<tr>
<td> </td>
<td bgcolor="#CCCCCC"><span class="style3 style13"><strong>
<label>
<input name="power2" type="checkbox" id="power2" onclick="JavaScript:fncShowHideInput(this);" />
Volt AC</label>
<label>
<input name="v_AC" type="text" id="v_AC" style="width:50px; display:none" autocomplete="off" />
</label>
(v)</strong></span></td>
<td bgcolor="#CCCCCC"><span class="style13 style3"><strong>
<label>
<input name="Air2" type="checkbox" id="Air2" value="1" />
พัดลมฝาบน</label>
</strong></span></td>
<td> </td>
</tr>
<tr>
<td> </td>
<td bgcolor="#CCCCCC"><span class="style3 style13"><strong>
<label>
<input name="power3" type="checkbox" id="power3" onclick="JavaScript:fncShowHideInput2(this);"/>
Volt DC</label>
<input type="text" name="v_DC" id="v_DC" style="width:50px; display:none" autocomplete="off" />
(v)</strong></span></td>
<td bgcolor="#CCCCCC"><span class="style13 style3"><strong>
<label>
<input name="Air3" type="checkbox" id="Air3" value="1" />
พัดลม Node</label>
</strong></span></td>
<td> </td>
</tr>
<tr>
<td> </td>
<td bgcolor="#CCCCCC"><span class="style3 style13"><strong>
<label>
<input name="power4" type="checkbox" id="power4" value="1" />
Breaker (AC)</label>
</strong></span></td>
<td bgcolor="#CCCCCC"><span class="style13 style3"><strong>
<label>
<input name="Air4" type="checkbox" id="Air4" value="1" />
แผ่น Filter </label>
</strong></span></td>
<td> </td>
</tr>
<tr>
<td> </td>
<td bgcolor="#CCCCCC"><span class="style3 style13"><strong>
<label>
<input name="power5" type="checkbox" id="power5" value="1" />
Breaker (DC)</label>
</strong></span></td>
<td bgcolor="#CCCCCC"><span class="style13 style3"><strong>
<label>
<input name="Air5" type="checkbox" id="Air5" value="1" />
เป่า ทำความสะอาด</label>
</strong></span></td>
<td> </td>
</tr>
<tr>
<td> </td>
<td bgcolor="#CCCCCC"><span class="style3 style13"><strong>
<label>
<input name="power6" type="checkbox" id="power6" onclick="JavaScript:fncShowHideInput3(this);" />
Battery</label>
<input type="text" name="batt" id="batt" style="width:50px; display:none" autocomplete="off"/>
(v)</strong></span></td>
<td bgcolor="#CCCCCC"> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td bgcolor="#FF0000"><span class="style14 style8 style15"><strong>ตอนนอก</strong></span></td>
<td bgcolor="#FF0000"><span class="style8 style14 style15"><strong>สภาพทั่วไป</strong></span></td>
<td> </td>
</tr>
<tr>
<td> </td>
<td bgcolor="#CCCCCC"><span class="style3 style13"><strong>
<label>
<input name="outside1" type="checkbox" id="outside1" value="1" />
Jumper</label>
</strong></span></td>
<td bgcolor="#CCCCCC"><span class="style3 style13"><strong>
<label>
<input name="other1" type="checkbox" id="other1" value="1" />
ตู้ Node</label>
</strong></span></td>
<td> </td>
</tr>
<tr>
<td> </td>
<td bgcolor="#CCCCCC"><span class="style3 style13"><strong>
<label>
<input name="outside2" type="checkbox" id="outside2" value="1" />
แผงตอนนอก + กันฟ้า</label>
</strong></span></td>
<td bgcolor="#CCCCCC"><span class="style3 style13"><strong>
<label>
<input name="other2" type="checkbox" id="other2" value="1" />
OFC</label>
</strong></span></td>
<td> </td>
</tr>
<tr>
<td> </td>
<td bgcolor="#CCCCCC"><span class="style3 style13"><strong>
<label>
<input name="outside3" type="checkbox" id="outside3" value="1" />
รู Cable</label>
</strong></span></td>
<td bgcolor="#CCCCCC"><span class="style3 style13"><strong>
<label>
<input name="other3" type="checkbox" id="other3" value="1" />
Patch Cord</label>
</strong></span></td>
<td> </td>
</tr>
<tr>
<td> </td>
<td bgcolor="#CCCCCC"><span class="style3 style13"><strong>
<label>
<input name="outside4" type="checkbox" id="outside4" value="1" />
Ground</label>
</strong></span></td>
<td bgcolor="#CCCCCC"><span class="style3 style13"><strong>
<label>
<input name="other4" type="checkbox" id="other4" value="1" />
Label</label>
</strong></span></td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td><label></label><label></label></td>
<td colspan="2" bgcolor="#FF0000"><span class="style19">หมายเหตุ</span></td>
<td> </td>
</tr>
<tr>
<td> </td>
<td colspan="2" bgcolor="#CCCCCC"><label>
<textarea name="note" id="note" style="width:480px; height:50px "></textarea>
</label></td>
<td> </td>
</tr>
<tr>
<td colspan="4" align="center"> </td>
</tr>
<tr>
<td colspan="4" align="center"><label>
<input type="submit" name="button" id="button" value="ยืนยันการเพิ่มข้อมูล" onclick="return confirm('ยืนยันการเพิ่มข้อมูล')" />
</label>
<label>
<input type="reset" name="button2" id="button2" value="ล้าง" />
</label></td>
</tr>
</table>
</form>
</body>
</html>
|
|
|
|
|
Date :
2012-03-29 14:46:34 |
By :
akkaneetha |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
คุณบอกว่า กด Select All แล้ว Textbox ไม่มา งั้นก็แสดงว่าเป็นที่ ฟังก์ชัน CheckAll()
Code (PHP)
function CheckAll() {
for (var i = 0; i < document.form1.elements.length; i++) {
if(document.form1.elements[i].type == 'checkbox'){
document.form1.elements[i].checked = !(document.form1.elements[i].checked);
}
}
}
คุณก็แค่เพิ่ม
Code (PHP)
input1.style.display='';
input2.style.display='';
input3.style.display='';
ลงในฟังก์ชัน CheckAll()
หรือจะลองเขียนเป็นลูป คล้าย Checkbox ก็ได้ครับ
|
ประวัติการแก้ไข 2012-03-29 15:35:52
|
|
|
|
Date :
2012-03-29 15:34:54 |
By :
50121680 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 00
|