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

Registered : 89,022

 
 
HOME > Javascript Tips & Tricks : การใช้งาน JavaScript ร่วมกับ Form > JavaScript Fixed Size and Get Size in HTML Element

JavaScript Fixed Size and Get Size in HTML Element

 
 


Bookmark.   
Share
       
JavaScript Fixed Size and Get Size in HTML Element เป็นตัวอย่างการ JavaScript กับ Get Size in HTML Element ในการตรวจสอบและกำหนดค่าความกว้างของ Textbox

ตัวอย่างที่ 1 ตรวจสอบขนาดความกว้างของ Textbox

fixed_size_html_element1.html

<html>
<head>
<title>ThaiCreate.Com Tutorial</title>
</head>
<body>
<script language="JavaScript"> 
 	 function fncChkSize1()
	 {
		var ele = document.getElementById("txtA");
		alert (ele.size)
	 }

 	 function fncChkSize2()
	 {
		var ele = document.getElementById("txtB");
		alert (ele.style.width)
	 }
</script>
<body>
	<form name="frmMain" method="post">
			<input name="txtA" size="50" type="text" id="txtA" value=""> 
			<input name="chkSize1" type="button" id="chkSize1" onClick="Javascript:fncChkSize1();" value="Check Size">
			<hr>
			<input name="txtB" type="text" id="txtB" value="" style="width:100px"> 
			<input name="chkSize2" type="button" id="chkSize2" onClick="Javascript:fncChkSize2();" value="Check Size">
	</form>
</body>
</html>


Screenshot

JavaScript Fixed Size and Get Size in HTML Element


ตัวอย่างที่ 2 การขยายขนาดของ Textbox

fixed_size_html_element2.html

<html>
<head>
<title>ThaiCreate.Com Tutorial</title>
</head>
<body>
<script language="JavaScript"> 
 	 function fncFixedSize1()
	 {
		var ele = document.getElementById("txtA");
		ele.size = 100;
		alert (ele.size)
	 }

 	 function fncFixedSize2()
	 {
		var ele = document.getElementById("txtB");
		ele.style.width = "100px";
		alert (ele.style.width)
	 }
</script>
<body>
	<form name="frmMain" method="post">
			<input name="txtA" type="text" id="txtA" value=""> 
			<input name="fixedSize1" type="button" id="fixedSize1" onClick="Javascript:fncFixedSize1();" value="Fixed Size">
			<hr>
			<input name="txtB" type="text" id="txtB" value=""> 
			<input name="fixedSize2" type="button" id="fixedSize2" onClick="Javascript:fncFixedSize2();" value="Fixed Size">
	</form>
</body>
</html>


Screenshot

JavaScript Fixed Size and Get Size in HTML Element

   
Share




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

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


   
  By : ThaiCreate.Com Team (บทความเป็นลิขสิทธิ์ของเว็บไทยครีเอทห้ามนำเผยแพร่ ณ เว็บไซต์อื่น ๆ)
  Score Rating :  
  Create/Update Date : 2011-06-19 11:59:15 / 2011-06-19 12:03:29
  View : 9,044
  Download : No files
Sponsored Links
  Download Google Chorme
 
Ads Contact : 08-1987-6107 , 08-4715-5121
Download Mozilla Firefox
 
Ads Contact : 08-1987-6107 , 08-4715-5121
 Sponsored Links / Related


 
JavaScript Submit & Button
Rating : View : 37,434
JavaScript alert & confirm
Rating : View : 84,292
JavaScript HTML Submit Form
Rating : View : 39,191
JavaScript Keyboard & Event
Rating : View : 12,672
JavaScript HTML Multiple Action Form
Rating : View : 30,939
JavaScript innerHTML & InnerText
Rating : View : 11,363
JavaScript HTML Check Input TextBox/Text Field
Rating : View : 57,651
JavaScript Check Password / Confirm Password
Rating : View : 17,886
JavaScript HTML Check Checkbox
Rating : View : 46,048
JavaScript HTML Check Radio Button
Rating : View : 48,689
JavaScript HTML Back/Next/Close/Print
Rating : View : 30,390
JavaScript HTML Disable & Enable Html Element
Rating : View : 26,491
JavaScript HTML Show/Hide Html Element
Rating : View : 29,219
JavaScript Auto Print Preview
Rating : View : 52,291
JavaScript Reload/Refresh Webpage
Rating : View : 30,146
JavaScript Auto Redirect
Rating : View : 25,430
JavaScript Timers Delay setTimeout
Rating : View : 31,818
HTML Redirect / Refresh Webpage
Rating : View : 27,703
JavaScript Click Check All and Un Check All
Rating : View : 18,462
JavaScript & AJAX
Rating : View : 13,282
JavaScript Cookies
Rating : View : 10,218
JavaScript Prompt
Rating : View : 9,462
JavaScript Disabled Element
Rating : View : 9,385
JavaScript Display Element
Rating : View : 9,697
JavaScript Visibility & Display
Rating : View : 9,449
JavaScript Check Validate Number only input
Rating : View : 18,712
JavaScript Check Event Key Codes / Keyboard
Rating : View : 11,666
JavaScript Disable Enter Submit Form
Rating : View : 10,796
JavaScript Disable IE (Internet Explorer) Close Button.
Rating : View : 10,437
JavaScript Print Webpage and Using CSS
Rating : View : 11,905
JavaScript Sum Total Value From Textbox
Rating : View : 14,369
JavaScript Change Display Image from JavaScript
Rating : View : 10,705
JavaScript/jQuery Display Preview Images Before Upload
Rating : View : 17,552
JavaScript Add/Remove Item in ListMenu/DropDownList
Rating : View : 12,911
JavaScript substring
Rating : View : 9,822
JavaScript split
Rating : View : 10,316
JavaScript trim
Rating : View : 9,498
JavaScript Count String Length
Rating : View : 13,014
JavaScript Change Textbox Stylesheet / CSS
Rating : View : 11,003
JavaScript Get/Read all element on Webpage
Rating : View : 9,436
JavaScript Popup Window
Rating : View : 15,361
JavaScript Display Full Screen WebPage
Rating : View : 10,448
Javascript Enter and AutoFocus Next Textbox (Up and Down Keyword)
Rating : View : 11,551
JavaScript Disable Right-Click
Rating : View : 9,664
JavaScript Disable Text Selection on Webpage When Drag-and-Drop
Rating : View : 9,841
JavaScript Auto Select Text When Click TextBox
Rating : View : 10,568
JavaScript Auto Clear Text When Click TextBox
Rating : View : 10,529
JavaScript Create Cookies , Read Cookies , Delete Cookies
Rating : View : 9,162
JavaScript createElement or element control
Rating : View : 8,878
JavaScript Get a Screen Resolution Detection
Rating : View : 9,409
JavaScript: Check File Extension Before Upload
Rating : View : 1,623
JavaScript createElement Without Array
Rating : View : 8,917
JavaScript createElement and Create DropDownList/ListMenu
Rating : View : 10,610
JavaScript createElement Select and Get item from MySql Database
Rating : View : 12,479
JavaScript Change Display Image When MouseOver
Rating : View : 11,183
JavaScript Dependency Dependant and MySQL Database
Rating : View : 8,805
JavaScript Click Checkbox and Highlight Background Color table
Rating : View : 10,309
JavaScript Mark all the Checkbox and Background Color the Table After Checked Checkbox
Rating : View : 11,121
JavaScript When Cell Click Highlight BackGround Color , BgColor in a Table
Rating : View : 8,987
Javascript Table Cell Highlight Background Colors Change on Mouseover
Rating : View : 10,735
JavaScript Get element with array
Rating : View : 9,901
JavaScript Dynamic Dependant DropDownList/ListMenu
Rating : View : 9,998
JavaScript Send Data from Popup to Main form
Rating : View : 12,589
JavaScript Send Checkbox Data from Popup to Main form
Rating : View : 12,545
JavaScript isNaN() Check Number
Rating : View : 11,847
JavaScript ParseFloat() Convert String to Number
Rating : View : 9,417
JavaScript ParseInt() Convert String to Integer
Rating : View : 9,462
JavaScript Ceil() Round fractions up
Rating : View : 8,587
JavaScript toFixed() Formatting numbers for currency
Rating : View : 9,395
JavaScript toExponential() Converts to exponential notation.
Rating : View : 8,388
JavaScript toPrecision() Formats Specified length
Rating : View : 8,047
JavaScript valueOf()
Rating : View : 8,394
JavaScript toUpperCase() Convert Uppercase String
Rating : View : 8,297
JavaScript toLowerCase() Convert Lower String
Rating : View : 8,149
JavaScript substr() Sub String
Rating : View : 8,573
JavaScript toString() Convert to String
Rating : View : 8,294
JavaScript Number Format and Comma
Rating : View : 11,334
JavaScript replace() Replace string
Rating : View : 8,688
JavaScript random() Random number
Rating : View : 8,971
JavaScript round() Round Nearest integer
Rating : View : 8,161
JavaScript DateAdd() AddDay , AddMonth , AddYear
Rating : View : 7,907
JavaScript DateDiff() Calculating the difference date time
Rating : View : 2,251
JavaScript TimeDiff() Calculating the difference time
Rating : View : 1,573
JavaScript Compare DateTime to compare difference
Rating : View : 1,887
JavaScript Date() Day , Month , Year , Second , Minutes , Hours
Rating : View : 2,407
JavaScript Get Selection Text from DropDownList/ListMenu
Rating : View : 11,122
JavaScript Check and Detection Web Browser
Rating : View : 8,833
Javascript Disable Backspace on KeyPress
Rating : View : 11,263
Javascript Disable Enter Submit and Backspace on KeyPress
Rating : View : 9,490
JavaScript Creating Add to Favorites Button
Rating : View : 9,258
JavaScript Show and Hide Table Rows
Rating : View : 11,526
JavaScript Create/Remove/Delete Dynamic Table Rows
Rating : View : 13,309
JavaScript setTimeOut & Loop
Rating : View : 10,478
JavaScript Text Box Characters Counter
Rating : View : 9,535
JavaScript Redirect/Redirection Web Page
Rating : View : 9,127
JavaScript get offsetWidth and offsetHeight
Rating : View : 8,829
JavaScript Input type file: Changing browse button
Rating : View : 11,007
JavaScript Move Maximize Window From JavaScript
Rating : View : 9,021
JavaScript visibility hidden & visible
Rating : View : 9,325
CSS Page Break on Printing
Rating : View : 11,144




Comunity Forum Free Web Script
Jobs Freelance Free Uploads
Free Web Hosting Free Tools
ThaiCreate.Com Logo
© www.ThaiCreate.Com. 2003-2013 All Rights Reserved. Link : ติดแก๊ส , ติดแก๊สรถยนต์
เพื่อนบ้าน : Chevrolet , Toyota , Honda , Nissan

for Contact Us : [Conditions Privacy Statement] ติดต่อโฆษณา 081-987-6107 , 084-715-5121 อัตราราคา คลิกที่นี่

Back to Top