|
|
|
เช็คจำนวนตัวอักษรใน textarea ไม่ได้ครับ ใน firefox |
|
|
|
|
|
|
|
บางครั้งผมก็เป็นเหมือนกัน...แต่ก็ยังแก้ไมได้เลย
|
|
|
|
|
Date :
2010-08-03 10:06:05 |
By :
Mitsumasa |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ครับผม ผมก็หาทางแก้อยู่เหมือกันครับ
|
|
|
|
|
Date :
2010-08-03 11:05:17 |
By :
popzila27 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
เอา Code มาให้ดูหน่อยครับ
|
|
|
|
|
Date :
2010-08-03 11:35:40 |
By :
webmaster |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Code (JavaScript)
<meta http-equiv="Content-Type" content="text/html; charset=tis-620">
<link href="./css/css_class.css" rel="stylesheet" type="text/css">
<script language="JavaScript" src="./functions/main_function.js"></script>
<script language="javascript">
var ns6=document.getElementById&&!document.all;
var englimit =70;
var thlimit =70;
function restrictinput(maxlength,e,placeholder,objcheck) {
var m=englimit;
var t = eval(placeholder);
for(var i=0;i<=t.value.length;i++){
if(eval(t.value.charCodeAt(i))>=3585){
m=thlimit;
break;
}
}
var evt = checkvalid(e);
if (evt&&event.srcElement.value.length>=m){
var overlimit = t.value.length-m;
var intext = t.value.substring(0,m);
t.value = intext;
return false;
}
}
function countlimit(maxlength,e,placeholder,objcheck){
var m=englimit;
var theform=eval(placeholder);
var lengthleft=0;
for(var i=0;i<=theform.value.length;i++){
if(eval(theform.value.charCodeAt(i))>=3585)
{ m=thlimit;
break;
}else{
m=englimit;
break;
}
}
if(theform.value.length<=m){
lengthleft=theform.value.length;
}else{
lengthleft=theform.value.length-m;
lengthleft="<font color=#cc0000>-"+lengthleft+"</font>";
}
var placeholderobj=document.all? document.all[placeholder] : document.getElementById(placeholder);
if (window.event||e.target&&e.target==eval(placeholder)){
if (lengthleft<0)
theform.value=theform.value.substring(0,m)
placeholderobj.innerHTML=lengthleft;
}
}
function displaylimit(thename, theid, thelimit){
var theform=theid!=""? document.getElementById(theid) : thename;
var limit_text='<span id="'+theform.toString()+'">0</span>';
if (document.all||ns6)
document.write(limit_text);
if (document.all){
eval(theform).onkeypress=function(){ return restrictinput(thelimit,event,theform)}
eval(theform).onkeyup=function(){ return countlimit(thelimit,event,theform)}
}
else if (ns6){
document.body.addEventListener('keypress', function(event) { restrictinput(thelimit,event,thename)}, true);
document.body.addEventListener('keyup', function(event) { countlimit(thelimit,event,theform) }, true);
}
}
นี่เป็นส่วน จาวาสคลิปครับ
<td class="bold" style="width:70;text-align:left;vertical-align:top;"> <div align="center">พิมพ์ไปแล้ว<br><br><script>displaylimit("","txtMessage",englimit)</script><br><br>ตัวอักษร</div></td>
ส่วนนี่เป็นส่วนที่กรอกข้อความครับ
|
|
|
|
|
Date :
2010-08-03 11:53:49 |
By :
popzila27 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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=windows-874" />
<title>Untitled Document</title>
</head>
<style type="text/css">
.progress{
width: 1px;
height: 14px;
color: white;
font-size: 12px;
overflow: hidden;
background-color: navy;
padding-left: 5px;
}
</style>
<script type="text/JavaScript">
/***********************************************
* Form Field Progress Bar- By Ron Jonk- http://www.euronet.nl/~jonkr/
* Modified by Dynamic Drive for minor changes
* Script featured/ available at Dynamic Drive- http://www.dynamicdrive.com
* Please keep this notice intact
***********************************************/
function textCounter(field,counter,maxlimit,linecounter) {
// text width//
var fieldWidth = parseInt(field.offsetWidth);
var charcnt = field.value.length;
// trim the extra text
if (charcnt > maxlimit) {
field.value = field.value.substring(0, maxlimit);
}
else {
// progress bar percentage
var percentage = parseInt(100 - (( maxlimit - charcnt) * 100)/maxlimit) ;
document.getElementById(counter).style.width = parseInt((fieldWidth*percentage)/100)+"px";
document.getElementById(counter).innerHTML="Limit: "+percentage+"%"
// color correction on style from CCFFF -> CC0000
setcolor(document.getElementById(counter),percentage,"background-color");
}
}
function setcolor(obj,percentage,prop){
obj.style[prop] = "rgb(80%,"+(100-percentage)+"%,"+(100-percentage)+"%)";
}
</script>
<body>
<form>
<textarea rows="5" cols="40" name="maxcharfield" id="maxcharfield"
onKeyDown="textCounter(this,'progressbar1',20)"
onKeyUp="textCounter(this,'progressbar1',20)"
onFocus="textCounter(this,'progressbar1',20)" ></textarea><br />
<div id="progressbar1" class="progress"></div>
<script>textCounter(document.getElementById("maxcharfield"),"progressbar1",20)</script>
</form>
</body>
</html>
แบบนี้คงจะได้นะ
ขอบคุณเวป DMD
|
ประวัติการแก้ไข 2010-08-03 14:00:05 2010-08-03 14:00:30
|
|
|
|
Date :
2010-08-03 13:55:07 |
By :
compeng |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ขอบคุณครับผม เดี๋ยวเอาไปลองดูครับ
|
|
|
|
|
Date :
2010-08-03 14:59:43 |
By :
popzila27 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ยังไม่ได้เลยครับ ใครพอมีวิธี ไหนอีกไหมครับผม
|
|
|
|
|
Date :
2010-08-05 12:05:14 |
By :
popzila27 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 05
|