// by ID
function insertText(val,e){ document.getElementById(e).value =val; }
//วิธีใช้ใน html onclick=”insertText(‘TestValue’,’elementsID’)
function add(text){ var TheTextBox = document.getElementById("elementsID"); TheTextBox.value = text; }
//วิธีใช้ใน html onclick=”add(‘TestValue’)
//——————————————————————————
//by field name
function add1(text){ var TheTextBox = document.forms[0].elements['FieldName']; TheTextBox.value = text; }
//วิธีใช้ใน html onclick=”add1(‘TestValue’)
//——————————————————————————
//by field name
function add2(text,fieldName){ var TheTextBox = document.forms[0].elements[fieldName]; TheTextBox.value = text; }
//วิธีใช้ใน html onclick=”add2(‘TestValue’,’fieldName’)
แปะไว้กันลืม copy เขามาอีกทีแล้วมาแก้นิดหน่อยCR. http://www.dynamicdrive.com/forums/showthread.php?34869-Adding-Text-Into-Textbox-with-JavaScript