Jquery+how to get the value of each element in the form

hi to all,

I am using jquery 1.3.2

I have a form like below


<form id='frmRegister' action='...' method='post'>
<table id='tabReg' >

<tr>
<td><input type="text" name="first_name" id="first_name" ></td>
</tr>


<tr>
<td><input type="radio" name="sampleRadio" id="sampleRadio" ></td>
</tr>


<tr>
<td><input type="checkbox" name="chk" id="chk" ></td>
</tr>

<tr>
<td><select name='city' id='city'>
<option value='1'>ddd</option>
</select>
</td>
</tr>

<tr>
<td><input type='button' id='btnreg' value='Register' >
</td>
</tr>
</table
</form>


i want to get the each form element name attribute through each funtion

like


$("#frmRegister").each(function(){
alert($(this).val);
});

how i can do this because i want to get all element no matter it is select , radio ,checkbox textarrea

regards


$("input").each(function(){
alert($(this).attr("id") + " has a value of " + $(this).val());
});

Would get all the input values…

Im not sure how well this would work, havnt tested it…


$("#frmRegister").children("input").each(function(){
alert($(this).attr("id") + " has a value of " + $(this).val());
});

Not sure if I fully get your question, but I interpret it as you want to select all possible form inputs.

If so, look at this selector:

http://docs.jquery.com/Selectors/input