Reply
Get value of inputs with Jquery
Old 03-06-2010, 12:52 PM Get value of inputs with Jquery
Junior Talker

Posts: 1
Trades: 0
I have 100 inputs with name - table[].
How to get their value with jQuery,like $_POST['table'] ,as I do in PHP.
I tryed
Code:
$("input[name='table[]']").each(function() {
	document.write($(this).val());
	
		
});
but I want to get them as an array.
lam3r4370 is offline
Reply With Quote
View Public Profile
 
 
When You Register, These Ads Go Away!
Old 03-06-2010, 04:32 PM Re: Get value of inputs with Jquery
wayfarer07's Avatar
Eat You

Posts: 3,570
Name: Abel Mohler
Location: Asheville, North Carolina USA
Trades: 0
As soon as you select it, it's already an array. For example, you could do this:
Code:
var inputs = $("input[name='table[]']")
for(var i = 0; i < inputs.length; i++) {
    document.write(inputs[i].value);
}
The only disadvantage of doing it this way is if you select a member through its index, you can't chain special jQuery methods to it, such as .each(), or .val().

jQuery selection always returns an array, even if it is only one member. The value of each index in the array is the "raw" DOM object. For example:
Code:
alert($('#unique').html());
is the same as:
Code:
alert($('#unique')[0].innerHTML);
__________________
Wayfarer | bBoard
If Google is the Coca-Cola of Web search, Bing is RC Cola

Last edited by wayfarer07; 03-06-2010 at 04:34 PM..
wayfarer07 is online now
Reply With Quote
View Public Profile Visit wayfarer07's homepage!
 
Reply     « Reply to Get value of inputs with Jquery
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 


Page generated in 0.10085 seconds with 13 queries