Can any one provide me an example to loop through all the form fields and to show those fields except hidden fields in that form.
Pseudo code:
for(i=0;i<formFields.length;i++)
{
if(formFields[i]!= 'hidden field')
then formFields[i].show();
}
You could try looping through the fields with the following code; however, if the fields have a hidden attribute they will be hidden. No need to apply .show
to elements that will already be displayed.
Loop through all visibile fields:
$("#Form1 :input").not(':button, :hidden').each(function() {
// do whatever with the fields here
});
Update
// show form, clear hidden values
$(".dropdown").on('change', function() {
if ($(this).val() == "Show all fields") {
$("#Form1").show();
$("#Form1 :input").is(':hidden').each(function() {
$(this).val('');
});
}
});
Update 2:
$(".dropdown").on('change', function() {
if ($(this).val() == "Show all fields") {
$("#Form1").show();
$('#Form1 *').filter(':input').each(function() {(...)});
}
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With