Forum Moderators: open
<div id="popCustomer">
<table>
<tr>
<td>
<input name="cust_comp_name" type="text" maxlength="60" />
</td>
</tr>
<tr>
<td width="60%">
<input type="button" name="button" value="Save" onclick="addpop('popCustomer');" />
</td>
</tr>
</table>
</div>
The problem is that the existing code uses navigation of the DOM to locate the input fields
function addpop(id) {
// find all form inputs that are descendants of id
// and perform a function on each of the elements
$(id).find(':input').each(function(index, el) {
// Do something with each DOM element (this == el)
// save(this.value);
});
// Alternatively, you can get an array of the elements
var elArray = $(id).find(':input').toArray();
}
var out = [];
var formInputs = id.getElementsByTagName("input");
for (var i = 0; i < formInputs.length; i++)
{
out.push(formInputs.item(i));
}
var formInputs = id.getElementsByTagName("select");
for (i = 0; i < formInputs.length; i++)
{
out.push(formInputs.item(i));
}
var formTextArea = id.getElementsByTagName("textarea");
for (i = 0; i < formTextArea.length; i++)
{
out.push(formTextArea.item(i));
}