웹마스터 팁

동적 INPUT

2008.03.31 16:46

june44.myid.net/

미리보기 링크 :   http://june44.com/board/blog/55
 
<SCRIPT language=JavaScript>
function make_input(f, nm) {
 if(f.childNodes.item(0).name != nm) {
  if(document.all) cont = f.innerText;
  else    cont = f.textContent;
  if(cont.charCodeAt() == 32) cont = '';
  f.innerHTML = "<input type=text name='"+nm+"' value='"+cont+"' style='width:250px;' onBlur='del_input(this);' onfocusout='del_input(this);'>";
  f.childNodes.item(0).select();
  f.childNodes.item(0).focus();
 }
}
function del_input(f) {
 var cont = f.value;
 if(cont == '') cont = " ";
 cont = cont.replace(/s/, " ");
 var innerVal = cont + "<input type=hidden name='"+f.name+"' value='"+cont+"'>";
 f.parentNode.innerHTML = innerVal;
}
</SCRIPT>

<TABLE cellSpacing=1 cellPadding=0 width=300 align=center border=1>
<TBODY>
<TR align=middle height=25>
<TD onclick="make_input(this,'pm_upkeep[]')" align=middle width=300>여기를 클릭 해 보세요~^^ </TD></TR></TBODY></TABLE>