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,037

HOME > Javascript Tips & Tricks : การใช้งาน JavaScript ร่วมกับ Form > Javascript Table Cell Highlight Background Colors Change on Mouseover



Clound SSD Virtual Server

Javascript Table Cell Highlight Background Colors Change on Mouseover

Javascript Table Cell Highlight Background Colors Change on Mouseover เป็นตัวอย่างการ JavaScript กับ Mouseover Highlight Table Cell คือเมื่อมีการ Mouseover ผ่านที่ Cell จะมีการ Highlight สี Background ของ Cell ที่ Mouseover ผ่านในแถวนั้น ๆ


hilight_table_mouseover.html

<html>
<head>
<title>ThaiCreate.Com Tutorial</title>
</head>
<body>
<script language="JavaScript">

	function MakeColorOnMouseOver(ctrl)
	{
			document.getElementById(ctrl).bgColor='#CCCCCC'
	}

	function MakeColorOnMouseOut(ctrl)
	{
			document.getElementById(ctrl).bgColor='#FFFFFF'
	}

</script>
<form name="frmMain" action="" method="post" OnSubmit="return onDelete();">
<table width="600" border="1">
  <tr>
    <th width="91"> <div align="center">CustomerID </div></th>
    <th width="98"> <div align="center">Name </div></th>
    <th width="198"> <div align="center">Email </div></th>
    <th width="97"> <div align="center">CountryCode </div></th>
    <th width="59"> <div align="center">Budget </div></th>
    <th width="71"> <div align="center">Used </div></th>
  </tr>
  <tr id="tr1" OnMouseOver="MakeColorOnMouseOver('tr1');" OnMouseOut="MakeColorOnMouseOut('tr1');">
    <td><div align="center">C001</div></td>
    <td>Win Weerachai</td>
    <td>[email protected]</td>
    <td><div align="center">TH</div></td>
    <td align="right">1000000</td>
    <td align="right">600000</td>
  </tr>
  <tr id="tr2" OnMouseOver="MakeColorOnMouseOver('tr2');" OnMouseOut="MakeColorOnMouseOut('tr2');">
    <td><div align="center">C002</div></td>
    <td>John  Smith</td>
    <td>[email protected]</td>
    <td><div align="center">EN</div></td>
    <td align="right">2000000</td>
    <td align="right">800000</td>
  </tr>
  <tr id="tr3" OnMouseOver="MakeColorOnMouseOver('tr3');" OnMouseOut="MakeColorOnMouseOut('tr3');">
    <td><div align="center">C003</div></td>
    <td>Jame Born</td>
    <td>[email protected]</td>
    <td><div align="center">US</div></td>
    <td align="right">3000000</td>
    <td align="right">600000</td>
  </tr>
  <tr id="tr4" OnMouseOver="MakeColorOnMouseOver('tr4');" OnMouseOut="MakeColorOnMouseOut('tr4');">
    <td><div align="center">C004</div></td>
    <td>Chalee Angel</td>
    <td>[email protected]</td>
    <td><div align="center">US</div></td>
    <td align="right">4000000</td>
    <td align="right">100000</td>
  </tr>
</table>
</form>
</body>
</html>


Screenshot


Javascript Table Cell Highlight Background Colors Change on Mouseover



ตัวอย่างที่ 2 กรณีเขียนร่วม php กับ MySQL

Code
CREATE TABLE `customer` (
`CustomerID` varchar(4) NOT NULL,
`Name` varchar(50) NOT NULL,
`Email` varchar(50) NOT NULL,
`CountryCode` varchar(2) NOT NULL,
`Budget` double NOT NULL,
`Used` double NOT NULL,
PRIMARY KEY (`CustomerID`),
FULLTEXT KEY `Name` (`Name`,`Email`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

--
-- Dumping data for table `customer`
--

INSERT INTO `customer` VALUES ('C001', 'Win Weerachai', '[email protected]', 'TH', 1000000, 600000);
INSERT INTO `customer` VALUES ('C002', 'John Smith', '[email protected]', 'EN', 2000000, 800000);
INSERT INTO `customer` VALUES ('C003', 'Jame Born', '[email protected]', 'US', 3000000, 600000);
INSERT INTO `customer` VALUES ('C004', 'Chalee Angel', '[email protected]', 'US', 4000000, 100000);


hilight_table_mouseover.php

<html>
<head>
<title>ThaiCreate.Com Tutorial</title>
</head>
<body>
<script language="JavaScript">

	function MakeColorOnMouseOver(ctrl)
	{
			document.getElementById(ctrl).bgColor='#CCCCCC'
	}

	function MakeColorOnMouseOut(ctrl)
	{
			document.getElementById(ctrl).bgColor='#FFFFFF'
	}

</script>
<form name="frmMain" action="" method="post" OnSubmit="return onDelete();">
<?
$objConnect = mysql_connect("localhost","root","root") or die("Error Connect to Database");
$objDB = mysql_select_db("mydatabase");
$strSQL = "SELECT * FROM customer";
$objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]");
?>
<table width="600" border="1">
  <tr>
    <th width="91"> <div align="center">CustomerID </div></th>
    <th width="98"> <div align="center">Name </div></th>
    <th width="198"> <div align="center">Email </div></th>
    <th width="97"> <div align="center">CountryCode </div></th>
    <th width="59"> <div align="center">Budget </div></th>
    <th width="71"> <div align="center">Used </div></th>
  </tr>
<?
$i = 0;
while($objResult = mysql_fetch_array($objQuery))
{
$i++;
?>
  <tr id="tr<?php echo $i;?>" OnMouseOver="MakeColorOnMouseOver('tr<?php echo $i;?>');" OnMouseOut="MakeColorOnMouseOut('tr<?php echo $i;?>');">
    <td><div align="center"><?php echo $objResult["CustomerID"];?></div></td>
    <td><?php echo $objResult["Name"];?></td>
    <td><?php echo $objResult["Email"];?></td>
    <td><div align="center"><?php echo $objResult["CountryCode"];?></div></td>
    <td align="right"><?php echo $objResult["Budget"];?></td>
    <td align="right"><?php echo $objResult["Used"];?></td>
  </tr>
<?
}
?>
</table>
<?
mysql_close($objConnect);
?>
</form>
</body>
</html>


Screenshot

Javascript Table Cell Highlight Background Colors Change on Mouseover








   
Share


ช่วยกันสนับสนุนรักษาเว็บไซต์ความรู้แห่งนี้ไว้ด้วยการสนับสนุน Source Code 2.0 ของทีมงานไทยครีเอท


ลองใช้ค้นหาข้อมูล


   


Bookmark.   
       
  By : ThaiCreate.Com Team (บทความเป็นลิขสิทธิ์ของเว็บไทยครีเอทห้ามนำเผยแพร่ ณ เว็บไซต์อื่น ๆ)
  Score Rating :  
  Create/Update Date : 2011-06-19 08:00:38 / 2011-06-19 08:04:09
  Download : No files
 Sponsored Links / Related

 
JavaScript Submit & Button
Rating :

 
JavaScript alert & confirm
Rating :

 
JavaScript HTML Submit Form
Rating :

 
JavaScript Keyboard & Event
Rating :

 
JavaScript HTML Multiple Action Form
Rating :

 
JavaScript innerHTML & InnerText
Rating :

 
JavaScript HTML Check Input TextBox/Text Field
Rating :

 
JavaScript Check Password / Confirm Password
Rating :

 
JavaScript HTML Check Checkbox
Rating :

 
JavaScript HTML Check Radio Button
Rating :

 
JavaScript HTML Back/Next/Close/Print
Rating :

 
JavaScript HTML Disable & Enable Html Element
Rating :

 
JavaScript HTML Show/Hide Html Element
Rating :

 
JavaScript Auto Print Preview
Rating :

 
JavaScript Reload/Refresh Webpage
Rating :

 
JavaScript Auto Redirect
Rating :

 
JavaScript Timers Delay setTimeout
Rating :

 
HTML Redirect / Refresh Webpage
Rating :

 
JavaScript Click Check All and Un Check All
Rating :

 
JavaScript & AJAX
Rating :

 
JavaScript Cookies
Rating :

 
JavaScript Prompt
Rating :

 
JavaScript Disabled Element
Rating :

 
JavaScript Display Element
Rating :

 
JavaScript Visibility & Display
Rating :

 
JavaScript Check Validate Number only input
Rating :

 
JavaScript Check Event Key Codes / Keyboard
Rating :

 
JavaScript Disable Enter Submit Form
Rating :

 
JavaScript Disable IE (Internet Explorer) Close Button.
Rating :

 
JavaScript Print Webpage and Using CSS
Rating :

 
JavaScript Sum Total Value From Textbox
Rating :

 
JavaScript Change Display Image from JavaScript
Rating :

 
JavaScript/jQuery Display Preview Images Before Upload
Rating :

 
JavaScript Add/Remove Item in ListMenu/DropDownList
Rating :

 
JavaScript substring
Rating :

 
JavaScript split
Rating :

 
JavaScript trim
Rating :

 
JavaScript Count String Length
Rating :

 
JavaScript Change Textbox Stylesheet / CSS
Rating :

 
JavaScript Get/Read all element on Webpage
Rating :

 
JavaScript Popup Window
Rating :

 
JavaScript Display Full Screen WebPage
Rating :

 
Javascript Enter and AutoFocus Next Textbox (Up and Down Keyword)
Rating :

 
JavaScript Disable Right-Click
Rating :

 
JavaScript Disable Text Selection on Webpage When Drag-and-Drop
Rating :

 
JavaScript Auto Select Text When Click TextBox
Rating :

 
JavaScript Auto Clear Text When Click TextBox
Rating :

 
JavaScript Create Cookies , Read Cookies , Delete Cookies
Rating :

 
JavaScript createElement or element control
Rating :

 
JavaScript Get a Screen Resolution Detection
Rating :

 
JavaScript: Check File Extension Before Upload
Rating :

 
JavaScript createElement Without Array
Rating :

 
JavaScript createElement and Create DropDownList/ListMenu
Rating :

 
JavaScript createElement Select and Get item from MySql Database
Rating :

 
JavaScript Change Display Image When MouseOver
Rating :

 
JavaScript Dependency Dependant and MySQL Database
Rating :

 
JavaScript Click Checkbox and Highlight Background Color table
Rating :

 
JavaScript Mark all the Checkbox and Background Color the Table After Checked Checkbox
Rating :

 
JavaScript When Cell Click Highlight BackGround Color , BgColor in a Table
Rating :

 
JavaScript Get element with array
Rating :

 
JavaScript Dynamic Dependant DropDownList/ListMenu
Rating :

 
JavaScript Send Data from Popup to Main form
Rating :

 
JavaScript Send Checkbox Data from Popup to Main form
Rating :

 
JavaScript isNaN() Check Number
Rating :

 
JavaScript ParseFloat() Convert String to Number
Rating :

 
JavaScript ParseInt() Convert String to Integer
Rating :

 
JavaScript Ceil() Round fractions up
Rating :

 
JavaScript toFixed() Formatting numbers for currency
Rating :

 
JavaScript toExponential() Converts to exponential notation.
Rating :

 
JavaScript toPrecision() Formats Specified length
Rating :

 
JavaScript valueOf()
Rating :

 
JavaScript toUpperCase() Convert Uppercase String
Rating :

 
JavaScript toLowerCase() Convert Lower String
Rating :

 
JavaScript substr() Sub String
Rating :

 
JavaScript toString() Convert to String
Rating :

 
JavaScript Number Format and Comma
Rating :

 
JavaScript replace() Replace string
Rating :

 
JavaScript random() Random number
Rating :

 
JavaScript round() Round Nearest integer
Rating :

 
JavaScript DateAdd() AddDay , AddMonth , AddYear
Rating :

 
JavaScript DateDiff() Calculating the difference date time
Rating :

 
JavaScript TimeDiff() Calculating the difference time
Rating :

 
JavaScript MonthDiff() Calculating the difference month from two date time
Rating :

 
JavaScript Compare DateTime to compare difference
Rating :

 
JavaScript Date() Day , Month , Year , Second , Minutes , Hours
Rating :

 
JavaScript Get Selection Text from DropDownList/ListMenu
Rating :

 
JavaScript Check and Detection Web Browser
Rating :

 
Javascript Disable Backspace on KeyPress
Rating :

 
Javascript Disable Enter Submit and Backspace on KeyPress
Rating :

 
JavaScript Creating Add to Favorites Button
Rating :

 
JavaScript Show and Hide Table Rows
Rating :

 
JavaScript Create/Remove/Delete Dynamic Table Rows
Rating :

 
JavaScript setTimeOut & Loop
Rating :

 
JavaScript Text Box Characters Counter
Rating :

 
JavaScript Fixed Size and Get Size in HTML Element
Rating :

 
JavaScript Redirect/Redirection Web Page
Rating :

 
JavaScript get offsetWidth and offsetHeight
Rating :

 
JavaScript Input type file: Changing browse button
Rating :

 
JavaScript Move Maximize Window From JavaScript
Rating :

 
JavaScript visibility hidden & visible
Rating :

 
CSS Page Break on Printing
Rating :


ThaiCreate.Com Forum


Comunity Forum Free Web Script
Jobs Freelance Free Uploads
Free Web Hosting Free Tools

สอน PHP ผ่าน Youtube ฟรี
สอน Android การเขียนโปรแกรม Android
สอน Windows Phone การเขียนโปรแกรม Windows Phone 7 และ 8
สอน iOS การเขียนโปรแกรม iPhone, iPad
สอน Java การเขียนโปรแกรม ภาษา Java
สอน Java GUI การเขียนโปรแกรม ภาษา Java GUI
สอน JSP การเขียนโปรแกรม ภาษา Java
สอน jQuery การเขียนโปรแกรม ภาษา jQuery
สอน .Net การเขียนโปรแกรม ภาษา .Net
Free Tutorial
สอน Google Maps Api
สอน Windows Service
สอน Entity Framework
สอน Android
สอน Java เขียน Java
Java GUI Swing
สอน JSP (Web App)
iOS (iPhone,iPad)
Windows Phone
Windows Azure
Windows Store
Laravel Framework
Yii PHP Framework
สอน jQuery
สอน jQuery กับ Ajax
สอน PHP OOP (Vdo)
Ajax Tutorials
SQL Tutorials
สอน SQL (Part 2)
JavaScript Tutorial
Javascript Tips
VBScript Tutorial
VBScript Validation
Microsoft Access
MySQL Tutorials
-- Stored Procedure
MariaDB Database
SQL Server Tutorial
SQL Server 2005
SQL Server 2008
SQL Server 2012
-- Stored Procedure
Oracle Database
-- Stored Procedure
SVN (Subversion)
แนวทางการทำ SEO
ปรับแต่งเว็บให้โหลดเร็ว


Hit Link
   







Load balance : Server 00
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 อัตราราคา คลิกที่นี่