<div class="codetitle"> <span><a style="CURSOR: pointer" data="97423" class="copybut" id="copybut97423" onclick="doCopy('code97423')"><u>複製程式碼</u></a></span> 程式碼如下:</div> <div class="codebody" id="code97423"> <br><input name="title" type="text" size=" 50" value="{$p.title}" maxlength="15" onkeyup="javascript:setShowLength(this, 15, 'cost_tpl_title_length');"><span class="red" id="cost_tpl_title_length');"><span class="red" id="cost_tpl_title_length">還可以輸入15字數</span> <br></span> </div> <br>js: <br><div class="codetitle"> <span><a style="CURSOR: pointer" data="89137" class="copybut" id="copybut89137" onclick="doCopy('code89137')"><u>複製程式碼</u></a></span> 代碼如下</div> <div class="codebody" id="code89137"> <br>function setShowLength(obj, maxlength, id) <br>{ <br>var rem = maxlength - obj.value.length; <br>var wid = id; rem = 0; <br>} <br>document.getElementById(wid).innerHTML = "還可以輸入" rem "字數"; <br>} <br><br> </div>