Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to make list of all input field in a form with a $() function in jquery?
    primarykey
    data
    text
    <p>My HTML form is something like as follows</p> <pre><code>&lt;form id="form1" name="form1" method="post" action=""&gt; number: &lt;input name="formnum" type="text" id="input_1" tabindex="1" size="30" maxlength="30" /&gt; Title: &lt;select name="title" id="input_2" tabindex="2" &gt; &lt;option selected="selected" value=""&gt;&lt;/option&gt; &lt;option value="Mr." id="option_1 "&gt;Mr.&lt;/option&gt; &lt;option value="Mrs." id="option_2"&gt;Mrs.&lt;/option&gt; &lt;option value="Ms." id="option_3"&gt;Ms.&lt;/option&gt; &lt;option value="Dr." id="option_4"&gt;Dr.&lt;/option&gt; &lt;/select&gt; &lt;label&gt; &lt;input type="radio" name="gender" value="Male" id="input_3" tabindex="3"/&gt;Male &lt;/label&gt; &lt;label&gt; &lt;input type="radio" name="gender" value="Female" id="input_3"/&gt; Female&lt;/label&gt; First Name: &lt;input name="fname" type="text" id="input_5" tabindex="4" value="" size="30" maxlength="30" /&gt; Last Name: &lt;input name="lname" type="text" id="input_6" tabindex="5" value="" size="30" maxlength="30" /&gt; Address: &lt;input name="address" type="text" id="input_7" tabindex="6" value="" size="30" maxlength="30" /&gt; &lt;input type="submit" name="Submit" value="Submit" tabindex="16" /&gt; &lt;input type="reset" name="Submit2" value="Reset" tabindex="17" /&gt; &lt;/form&gt; </code></pre> <p>I want to make list of all input elements in a form in the sequence they appear in browser on <code>$(document).ready()</code>. I wrote following statement in jQuery to list out the <code>input</code> elements in a form in the sequence they appear in browser:</p> <pre><code>var textboxes = $("#form1 :input") </code></pre> <ol> <li>But this statement gives only list of elements having <code>input</code> tag i.e. all text boxes, radio buttons and submit buttons.</li> <li>It didn’t include the select box, text area, in the given list.</li> </ol> <p>This is my jQuery code:</p> <pre><code>$(document).ready(function(){ var textboxes = $("#form1 :input"), //gets all the textboxes images = $("img.classforimg"); //gets all the images images.hide(); //hide all of them except the first one alert(textboxes.length); textboxes.each(function (i){ var j = i; $(this).focus(function (){ images.hide(); //hide all of them except the first one images.eq(0).show(); images.eq(j).show(); }); }); **Here Jquery code for form validation** **Here Jquery code of Custom validation methods** }); </code></pre> <p><strong>Questions:</strong></p> <ol> <li>How could I get the the list of all elements in the form in the sequence they appear in browser on <code>$(document).ready()</code> including all input text boxes, group of radio buttons, check boxes, select boxes, textareas and buttons?</li> <li>The above statement considers radio buttons in above form as individual radio buttons and does not considers them as a group but actually above radio buttons are of same group. So how to solve these problem?</li> </ol> <p>Please help me friends! Thank You!</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload