Register Register Member Login Member Login Member Login Forgot Password ??
PHP , ASP , ASP.NET, VB.NET, C#, Java , jQuery , Android , iOS , Windows Phone
 

Registered : 109,027

HOME > PHP > PHP Forum > ขอคำแนะนำเมื่อคลิก checkbox แล้วให้ textfiled เปลี่ยนค่าด้วย



 

ขอคำแนะนำเมื่อคลิก checkbox แล้วให้ textfiled เปลี่ยนค่าด้วย

 



Topic : 121774



โพสกระทู้ ( 150 )
บทความ ( 0 )



สถานะออฟไลน์




ขอคำแนะนำเมื่อคลิก checkbox แล้วให้ textfiled เปลี่ยนค่าด้วย คือผมต้องการเมื่อคลิก checkbox "rdo2" ให้ textfiled "netsale" มีค่าเป็น "0" ด้วย พอจะมีวิธีใหมครับ code ที่เขียนอยู่แบบนี้ครับ

Code
<?php


header("Expires: Sat, 01 Jan 2000 00:00:00 GMT");
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
header("Cache-Control: post-check=0, pre-check=0",false);
session_cache_limiter("must-revalidate");
?>
<?  
session_start();   
if($_SESSION['userid'] == "")   {       
 header("location:login.php");    }   
//if($_SESSION['user_status'] != "esc")   
//{        
//echo "This page for User only!";      
//exit();   }      
mysql_connect("localhost","bpworld_root","root");
   
mysql_select_db("bpworld_opencart");
mysql_query("SET NAMES UTF8");
   
$strSQL = "SELECT * FROM user WHERE userid = '".$_SESSION['userid']."' ";    
$objQuery = mysql_query($strSQL);  
$objResult = mysql_fetch_array($objQuery);

$strSQLgp = "SELECT * FROM gp WHERE user = '".$objResult['user']."' ";    
$objQuerygp = mysql_query($strSQLgp);   
$Num_Rowsgp = mysql_num_rows($objQuerygp);

if($_POST["salecard"]== "")
{
$saledate =$_GET["saledate"];
$salecard =$_GET["salecard"];
}
else
{
$saledate =$_POST["saledate"];
$salecard =$_POST["salecard"];
}


?>

<html>
<head>
<title>BP WORLD ORDER</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <link rel="stylesheet" href="jquery-ui-1.9.1.custom/jquery-ui-1.9.1.custom/development-bundle/themes/base/jquery.ui.all.css">
	<script src="jquery-ui-1.9.1.custom/jquery-ui-1.9.1.custom/development-bundle/jquery-1.8.2.js"></script>
	<script src="jquery-ui-1.9.1.custom/jquery-ui-1.9.1.custom/development-bundle/ui/jquery.ui.core.js"></script>
	<script src="jquery-ui-1.9.1.custom/jquery-ui-1.9.1.custom/development-bundle/ui/jquery.ui.widget.js"></script>
	<script src="jquery-ui-1.9.1.custom/jquery-ui-1.9.1.custom/development-bundle/ui/jquery.ui.position.js"></script>
	<script src="jquery-ui-1.9.1.custom/jquery-ui-1.9.1.custom/development-bundle/ui/jquery.ui.menu.js"></script>
    <script src="jquery-ui-1.9.1.custom/jquery-ui-1.9.1.custom/development-bundle/ui/jquery.ui.datepicker.js"></script>
	<script src="jquery-ui-1.9.1.custom/jquery-ui-1.9.1.custom/development-bundle/ui/jquery.ui.autocomplete.js"></script>
	<link rel="stylesheet" href="jquery-ui-1.9.1.custom/jquery-ui-1.9.1.custom/development-bundle/demos/demos.css">
<script type="text/javascript">
$(document).ready(function(){
    $('#ProductName').autocomplete({
        source: "getdata.php?term="+$("#auto").val(),
		minLength: 2
    });
});
</script>


<style type="text/css">
.writh {
	color: #FFF;
	font-weight: bold;
	font-size: medium;
}
body {
	background-color: #F2F2F2;
}
.largefont {
	font-size: medium;
}
largefont {
	font-size: medium;
}
.fontsmall {
	font-size: small;
}
</style>
   

<script language="javascript">
function fncSubmit()
{
		
	if(document.form1.txtQty.value == "")
	{
		alert('กรุณาระบุจำนวนที่ขาย');
		document.form1.txtQty.focus();		
		return false;
	}
	
	
	else if(document.form1.netsale.value == "")
	{
		alert('กรุณาระบุราคาขายรวมสุทธิ');
		document.form1.netsale.focus();		
		return false;
	}
	
	else
	document.form1.submit();
}
</script>


    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="description" content="">
    <meta name="author" content="">
    <title>BP World Order</title>
    <link href="css/bootstrap.min.css" rel="stylesheet">
    <link href="css/font-awesome.min.css" rel="stylesheet">
    <link href="css/prettyPhoto.css" rel="stylesheet">
    <link href="css/price-range.css" rel="stylesheet">
    <link href="css/animate.css" rel="stylesheet">
	<link href="css/main.css" rel="stylesheet">
	<link href="css/responsive.css" rel="stylesheet">
    <!--[if lt IE 9]>
    <script src="js/html5shiv.js"></script>
    <script src="js/respond.min.js"></script>
    <![endif]-->       

    <style type="text/css">
    </style>
</head><!--/head-->
<style type="text/css">
.writh {
	color: #FFF;
	font-weight: bold;
	font-size: medium;
	text-align: center;
}

.largefont {
	font-size: medium;
}
largefont {
	font-size: medium;
}
.fontsmall {
	font-size: small;
}
</style>
<script language="javascript">
function IsNumeric(sText,obj)
{
	var ValidChars = "0123456789.";
   var IsNumber=true;
   var Char;
   for (i = 0; i < sText.length && IsNumber == true; i++) 
      { 
      Char = sText.charAt(i); 
      if (ValidChars.indexOf(Char) == -1) 
         {
         IsNumber = false;
         }
      }
   		if(IsNumber==false){
			alert("คีย์ได้เฉพาะ 0-9 และ . เท่านั้น");
			obj.value=sText.substr(0,sText.length-1);
		}
   }
</script>

<body>
	<header id="header"><!--header--><!--/header_top-->
	<table width="90%" border="0" align="center">
       <tr>
         <td height="35" align="center" bgcolor="#0066FF" class="writh">BP WORLD แจ้งยอดขาย</td>
       </tr>
     </table>
		<div class="header-middle"><!--header-middle-->
		  <div class="container"> 
          
<tr>
        <td align="left" bgcolor="#FF9900" class="writh"><?php echo $objResult['user'];?> <?php echo $objResult['branch'];?> </td>
       </tr>
     <table width="100%" border="1">
            <tr class="alert-info">
              <td width="38%">&nbsp;วันที่ขาย</td>
              <td width="62%">&nbsp;<?php echo $saledate ;?></td>
            </tr>
            <tr class="btn-info">
              <td>&nbsp;เลขที่ขาย No.</td>
              <td>&nbsp;<?php echo $salecard ;?></td>
            </tr>
          </table>
         
        <p><br><span class="largefont"><a href="show.php?&saledate=<? echo $saledate;?>&salecard=<? echo $salecard;?>"></a></span><a href="show.php?&saledate=<? echo $saledate;?>&salecard=<? echo $salecard;?>"><span class="largefont">สินค้าที่ท่านเลือก</span></a><span class="largefont"> | <a href="clear.php?&saledate=<? echo $saledate;?>&salecard=<? echo $salecard;?>">ล้างข้อมูลสินค้าที่ท่านเลือก</a></span> <span class="largefont"> | <a href="sale.php">เปลี่ยนเลขที่ขายหรือวันที่</a></span></p> 
            
          </div>
		</div><!--/header-middle-->
	
		<!--/header-bottom-->
	</header><!--/header-->
	
	  <!--form-->
	  <div class="container">
	    <div class="col-sm-4 col-sm-offset-1">
	        <div class="login-form">
	       
	        <h2>ค้นหาสินค้าที่ขาย</h2>
			
            <form name="frmSearch"  method="get" action="<?php echo $_SERVER['SCRIPT_NAME'];?>">
	             <input name="ProductName" type="text" id="ProductName" value="" size="30" placeholder="คีย์ชื่อรุ่นสินค้า">
                 <input name="salecard" type="hidden" id="salecard" value="<? echo $salecard; ?>" size="30" >
                 <input name="saledate" type="hidden" id="saledate" value="<? echo $saledate; ?>" size="30" >
	           
	            <button type="submit" class="btn btn-default">คลิกเพื่อค้นหา</button>
              </form>
            </div>
        </div>
      </div>

	<!--/form--><!--/Footer-->
	
    <?php
if($_GET["ProductName"] != "")
	{
	$objConnect = mysql_connect("localhost","bpworld_root","root") or die("Error Connect to Database");
	$objDB = mysql_select_db("bpworld_opencart");
	mysql_query("SET NAMES UTF8");
	// Search By Name or Email
	$strSQL1 = "SELECT * FROM product WHERE ProductName LIKE('".$_GET["ProductName"]."')";
	$objQuery1 = mysql_query($strSQL1) or die ("Error Query [".$strSQL1."]");
	$Num_Rows1 = mysql_num_rows($objQuery1);
	$objQuery1  = mysql_query($strSQL1);
	$objResult1 = mysql_fetch_array($objQuery1);
	
	
	$strSQL = "SELECT * FROM ms WHERE ms.shopcode='".$objResult['user']."' AND ms.productid = '".$objResult1 ['ProductID']."'";
	$objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]");
	$Num_Rows = mysql_num_rows($objQuery);
	$objQuery  = mysql_query($strSQL);
	

	?>

    
<div class="container">  

  <form action="order.php?&saledate=<? echo $saledate;?>&salecard=<? echo $salecard;?>" method="post"  name="form1" onSubmit="JavaScript:return fncSubmit();">
	<table width="100%"  border="2" cellpadding="2" cellspacing="2">
  <tr>
    <td colspan="2" align="center" bgcolor="#0066FF" class="writh">รายละเอียดสินค้าที่ขาย</td>
    </tr>
	<?php
	while($objResult = mysql_fetch_array($objQuery))
	{
	?>
	  <tr>
        <td height="30" bgcolor="#FFFF99">ชื่อรุ่น</td>
	    <td height="30" bgcolor="#FFFF99"><?php echo $_GET["ProductName"];?></td>
      </tr>
      <tr>
	    <td height="30" bgcolor="#FFFF99">ราคาต่อชิ้น</td>
	    <td height="30" bgcolor="#FFFF99"><input name="saleprice" type="text"  size="12" value="<?php echo $objResult["price"];?>"></td>
      </tr>
	  <tr>
	    <td height="14" bgcolor="#FFFF99">คงเหลือ</td>
	    <td height="14" bgcolor="#FFFF99"><input name="txt1" type="text" value="<?php echo $objResult["actqty"];?>" size="4"></td>
      </tr>
	  <tr>
	    <td height="30" bgcolor="#FFFF99">จำนวนชิ้นที่ขาย</td>
	    <td height="30" bgcolor="#FFFF99"><select name="txtQty">
	      <?php for($qty="";$qty<=10;$qty++)
	  {
	  ?>
	      <option value="<?php echo $qty;?>"><?php echo $qty;?></option>
	      <?php
	  }
	  ?>
        </select></td>
      </tr>
      
      <tr>
	    <td height="30" bgcolor="#FFFF99">ยอดขายรวมสุทธิ</td>
	    <td height="30" bgcolor="#FFFF99"><input name="netsale" type="text"  size="8" onKeyUp="IsNumeric(this.value,this)">
        &nbsp;&nbsp;<input name="rdo2" type="checkbox" value="0" onClick="javaScript:if(this.checked){document.all.netsale.style.display='none';}
else{document.all.netsale.style.display='';}">&nbsp;สินค้าแถม</td>
      </tr>
	  <tr>
	    <td height="30" bgcolor="#FFFF99"><input type="hidden" name="txtProductID" value="<?php echo $objResult["productid"];?>" size="2"></td>
       
	    <td height="30" bgcolor="#FFFF99"><input name="btnSubmit1" class="btn btn-default" type="submit" value="  ขายสินค้า  "></td>
      </tr>
      
	<?php
	}
	?>
	</table>
</form>

	
</div>

	<?php
	mysql_close($objConnect);
}	
	?>
</body>
</html>




Tag : PHP







Move To Hilight (Stock) 
Send To Friend.Bookmark.
Date : 2016-03-05 20:54:29 By : sranuwat View : 710 Reply : 3
 

 

No. 1



โพสกระทู้ ( 74,058 )
บทความ ( 838 )

สมาชิกที่ใส่เสื้อไทยครีเอท

สถานะออฟไลน์
Twitter Facebook

Quote:
<input name="rdo2" type="checkbox" value="0" onClick="javaScript:if(this.checked){document.all.netsale.style.display='none';}
else{document.all.netsale.style.display='';}">


ถ้าเป็ฯตรงนี้ผมว่ามันหาพวก Element ไม่เจอหรือเปล่าครับ ว่าแต่ทำไมไม่ใช้ jQuery ครับ

Code
onClick="javaScript:if(this.checked){$("#netsale").hide();}else{$("#netsale").show();}"


อย่าลืมนะครับว่า jQuery จะอ้างถึง Element โดยใช้ id






แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2016-03-06 11:01:51 By : mr.win
 


 

No. 2



โพสกระทู้ ( 150 )
บทความ ( 0 )



สถานะออฟไลน์


ได้แล้วครับ ผมใช้วิธีนี้แทน
Code
<script language="javascript">
function fncSubmit()
{
if(document.form1.rdo2.checked)
{
if(document.form1.txtQty.value == "")
{
alert('กรุณาระบุจำนวนที่ขาย');
document.form1.txtQty.focus();
return false;
}


else
document.form1.submit();
}
else
{
if(document.form1.txtQty.value == "")
{
alert('กรุณาระบุจำนวนที่ขาย');
document.form1.txtQty.focus();
return false;
}

else if(document.form1.netsale.value == "")
{
alert('กรุณาระบุราคาขายรวมสุทธิ');
document.form1.netsale.focus();
return false;
}

else
document.form1.submit();
}
}
</script>

แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2016-03-06 11:08:09 By : sranuwat
 

 

No. 3



โพสกระทู้ ( 9,556 )
บทความ ( 2 )



สถานะออฟไลน์


เวลาเอาไอค่อนภาษาโค๊ด ครอบ โค๊ด เลือกให้ตรงภาษาหน่อยครับ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2016-03-06 12:33:42 By : Chaidhanan
 

   

ค้นหาข้อมูล


   
 

แสดงความคิดเห็น
Re : ขอคำแนะนำเมื่อคลิก checkbox แล้วให้ textfiled เปลี่ยนค่าด้วย
 
 
รายละเอียด
 
ตัวหนา ตัวเอียง ตัวขีดเส้นใต้ ตัวมีขีดกลาง| ตัวเรืองแสง ตัวมีเงา ตัวอักษรวิ่ง| จัดย่อหน้าอิสระ จัดย่อหน้าชิดซ้าย จัดย่อหน้ากึ่งกลาง จัดย่อหน้าชิดขวา| เส้นขวาง| ขนาดตัวอักษร แบบตัวอักษร
ใส่แฟลช ใส่รูป ใส่ไฮเปอร์ลิ้งค์ ใส่อีเมล์ ใส่ลิ้งค์ FTP| ใส่แถวของตาราง ใส่คอลัมน์ตาราง| ตัวยก ตัวห้อย ตัวพิมพ์ดีด| ใส่โค้ด ใส่การอ้างถึงคำพูด| ใส่ลีสต์
smiley for :lol: smiley for :ken: smiley for :D smiley for :) smiley for ;) smiley for :eek: smiley for :geek: smiley for :roll: smiley for :erm: smiley for :cool: smiley for :blank: smiley for :idea: smiley for :ehh: smiley for :aargh: smiley for :evil:
Insert PHP Code
Insert ASP Code
Insert VB.NET Code Insert C#.NET Code Insert JavaScript Code Insert C#.NET Code
Insert Java Code
Insert Android Code
Insert Objective-C Code
Insert XML Code
Insert SQL Code
Insert Code
เพื่อความเรียบร้อยของข้อความ ควรจัดรูปแบบให้พอดีกับขนาดของหน้าจอ เพื่อง่ายต่อการอ่านและสบายตา และตรวจสอบภาษาไทยให้ถูกต้อง

อัพโหลดแทรกรูปภาพ

Notice

เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ
อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง

   
  เพื่อความปลอดภัยและการตรวจสอบ กระทู้ที่แทรกไฟล์อัพโหลดไฟล์จากที่อื่น อาจจะถูกลบทิ้ง
 
โดย
อีเมล์
บวกค่าให้ถูก
<= ตัวเลขฮินดูอารบิก เช่น 123 (หรือล็อกอินเข้าระบบสมาชิกเพื่อไม่ต้องกรอก)







Exchange: นำเข้าสินค้าจากจีน, Taobao, เฟอร์นิเจอร์, ของพรีเมี่ยม, ร่ม, ปากกา, power bank, แฟลชไดร์ฟ, กระบอกน้ำ

Load balance : Server 05
ThaiCreate.Com Logo
© www.ThaiCreate.Com. 2003-2024 All Rights Reserved.
ไทยครีเอทบริการ จัดทำดูแลแก้ไข Web Application ทุกรูปแบบ (PHP, .Net Application, VB.Net, C#)
[Conditions Privacy Statement] ติดต่อโฆษณา 081-987-6107 อัตราราคา คลิกที่นี่