Note that there are some explanatory texts on larger screens.

plurals
  1. POjQuery Chained Select Ajax - help needed
    primarykey
    data
    text
    <p>I recently posted my question <a href="https://stackoverflow.com/questions/5223777/jquery-to-update-select-list-not-like-the-other-questions">see previous question</a> and received a great working solution but when I applied the solution to my code, I found that if there was any html tags between the two selects, the second select list would not update. My guess is that the .next was not finding the class I was searching for. </p> <pre><code>&lt;cfloop query="rsRequestSystems"&gt; &lt;tr&gt; &lt;td&gt;&lt;select class="platform" name="platform" id="platform"&gt; &lt;option&gt;&lt;/option&gt; &lt;cfloop query="rsPlatform"&gt; &lt;option value="#rsPlatform.optionValue#" &lt;cfif rsRequestSystems.platform eq rsPlatform.optionValue&gt;selected&lt;/cfif&gt;&gt;#rsPlatform.optionDesc#&lt;/option&gt; &lt;/cfloop&gt; &lt;/select&gt;&lt;/td&gt; &lt;td&gt;&lt;select name="model" id="model"&gt; &lt;option&gt;&lt;/option&gt; &lt;cfloop query="rsModels"&gt; &lt;option value="#rsModels.optionValue#" &lt;cfif rsRequestSystems.model eq rsModels.optionValue&gt;selected&lt;/cfif&gt;&gt;#rsModels.optionDesc#&lt;/option&gt; &lt;/cfloop&gt; &lt;/select&gt;&lt;/td&gt; &lt;/tr&gt; </code></pre> <p></p> <p>and the jQuery code is:</p> <pre><code>$(".platform").live("change", function() { var firstOption = $(this); $.getJSON("index.cfm?do=misc.getModels",{platform: $(this).val()}, function(j){ var options = ''; for (var i = 0; i &lt; j.length; i++) { options += '&lt;option value="' + j[i].optionValue + '"&gt;' + j[i].optionDisplay + '&lt;/option&gt;'; } firstOption.next("#model").html(options); }); }); </code></pre> <p>and here is a sample of the json data being returned:</p> <pre><code>[{"optionValue":"", "optionDisplay":"Select Model"},] </code></pre>
    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.
 

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