Membaca input array menggunakan jquery


Membaca input array pada menggunakan jquery.
:input adalah semua komponen input.
[name=’tx[]’] adalah attribut dari input
Ketika tombol “Button” ditekan, maka akan menampilkan isi dari masing-masing text bergantian

<html>
<head>
<title>Input Array</title>
<link type=”text/css” href=”css/smoothness/jquery-ui-1.8.custom.css” rel=”stylesheet” />
<script type=”text/javascript” src=”smooth/js/jquery-1.4.2.min.js”></script>
<script type=”text/javascript” src=”smooth/js/jquery-ui-1.8.custom.min.js”></script>
<script type=”text/javascript”>
$(document).ready(function(){
$(“#btn”).click(function(){
$(“:input[name=’tx[]’]”).each(function(){
alert($(this).val());
});
});
});
</script>
</head>
<body>
<input type=”text” id=tx[] name=tx[] value=”satu”>
<input type=”text” id=tx[] name=tx[] value=”dua”>
<input type=”text” id=tx[] name=tx[] value=”tiga”>
<input type=”text” id=tx[] name=tx[] value=”empat”>
<input type=”text” id=tx[] name=tx[] value=”lima”>
<button id=btn>Button</button>
</body>
</html>

About abunajiyah
A Programmer

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: