การคัดลอกรหัสมีดังนี้:
<input name = "title" type = "text" size = "50" value = "{$ p.title}" maxlength = "15" onkeyup = "javascript: setshowLength (นี่, 15, 'cost_tpl _title_length');" > <span id = "cost_tpl_title_length"> คุณสามารถป้อน 15 คำ </span>
JS:
การคัดลอกรหัสมีดังนี้:
ฟังก์ชั่น setShowLength (obj, maxlength, id)
-
var rem = maxlength - obj.value.length;
var wid = id;
ถ้า (rem <0) {
rem = 0;
-
document.getElementById (wid) .innerhtml = "คุณยังสามารถป้อน" + rem + "จำนวนคำ";
-