Note that there are some explanatory texts on larger screens.

plurals
  1. POjquery wildcard selector - index of form element array
    primarykey
    data
    text
    <p>I've got a form with several multi-dimensional names. I am using the jquery *= selector to pick-out groups on them and perform functions when they change. I am trying to figure out how to get the individual array indexes of the form element name.</p> <p>I want to be able to identify the doorID by it's individual array 'parts'. e.g door_6x7, or 0 for <code>opening[door_6x7][0]</code></p> <p>JQUERY:</p> <pre><code> $("select[name*=door_6x]").change(function() { var doorID = $(this).attr("name"); alert(doorID); }); </code></pre> <p>SAMPLE HTML:</p> <pre><code> &lt;td width="50"&gt;&lt;select name="opening[door_6x7][0]"&gt; &lt;option value="0" selected="selected"&gt;0&lt;/option&gt; &lt;option value="1"&gt;1&lt;/option&gt; &lt;option value="2"&gt;2&lt;/option&gt; &lt;option value="3"&gt;3&lt;/option&gt; &lt;/select&gt;&lt;/td&gt; &lt;td width="50"&gt;&lt;select name="opening[door_6x7][1]"&gt; &lt;option value="0" selected="selected"&gt;0&lt;/option&gt; &lt;option value="1"&gt;1&lt;/option&gt; &lt;option value="2"&gt;2&lt;/option&gt; &lt;option value="3"&gt;3&lt;/option&gt; &lt;/select&gt;&lt;/td&gt; &lt;td width="50"&gt;&lt;select name="opening[door_6x7][2]"&gt; &lt;option value="0" selected="selected"&gt;0&lt;/option&gt; &lt;option value="1"&gt;1&lt;/option&gt; &lt;option value="2"&gt;2&lt;/option&gt; &lt;option value="3"&gt;3&lt;/option&gt; &lt;option value="4"&gt;4&lt;/option&gt; &lt;option value="5"&gt;5&lt;/option&gt; &lt;option value="6"&gt;6&lt;/option&gt; &lt;/select&gt;&lt;/td&gt; &lt;td width="50"&gt;&lt;select name="opening[door_6x7][3]"&gt; &lt;option value="0" selected="selected"&gt;0&lt;/option&gt; &lt;option value="1"&gt;1&lt;/option&gt; &lt;option value="2"&gt;2&lt;/option&gt; &lt;option value="3"&gt;3&lt;/option&gt; &lt;option value="4"&gt;4&lt;/option&gt; &lt;option value="5"&gt;5&lt;/option&gt; &lt;option value="6"&gt;6&lt;/option&gt; &lt;/select&gt;&lt;/td&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    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.
 

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