ดึงค่าจาก Text Input ที่ตั้งชื่อเป็น Array ด้วย Javascript

เอามาแป่ะกันลืมอย่างเคยอุอุ
ดูจาก code การทำงานก็คือ ถ้าคลิกที่ปุ่มก็จะไปเรียกฟังก์ชั่น getValueArray()เพื่อแสดงค่าใน Text Input ที่ตั้งชื่อเป็น Array ทั้งสองตัวครับ

<HTML>
<HEAD>

<script language="JavaScript" type="text/JavaScript">
function getValueArray(){
var arr = window.document.getElementsByName("ele[]");
var arr_length = arr.length;
for(i = 0; i < arr.length; i++){
alert(arr[i].value);

}
}
</script>

</HEAD>

<BODY>
<FORM METHOD=POST ACTION="" NAME="form1">
<INPUT TYPE="text" NAME="ele[]" ID="ele[]" VALUE="">
<INPUT TYPE="text" NAME="ele[]" ID="ele[]" VALUE="">
<INPUT TYPE="Button"  VALUE="Button" onclick="getValueArray();">
</FORM>
</BODY>
</HTML>

ตัวอย่างโปรแกรมที่ได้

You can leave a response, or trackback from your own site. Responses are currently closed, but you can trackback from your own site. You can skip to the end and leave a response. Pinging is currently not allowed. Both comments and pings are currently closed.
Powered by WordPress | Shop Free T-Mobile Phones Online | Thanks to Verizon Phones without Contract, MMORPG Games and Sell Car