Note that there are some explanatory texts on larger screens.

plurals
  1. POJQuery: Loading data from database and inserting it to select
    primarykey
    data
    text
    <p>I've three selects, which looks like this:</p> <pre><code>&lt;select name="nick"&gt; &lt;?php foreach ($chars as $char):?&gt; &lt;option value='&lt;?php echo $char['name'] ?&gt;'&gt;&lt;?php echo $char['name'] ?&gt;&lt;/option&gt; &lt;?php endforeach; ?&gt; &lt;/select&gt; &lt;select name='faction' disabled&gt; &lt;option value='ally'&gt;Alliance&lt;/option&gt; &lt;option value='horde'&gt;Horde&lt;/option&gt; &lt;/select&gt; &lt;select name='class' id="class" disabled&gt; &lt;option value='1'&gt;Warrior&lt;/option&gt; &lt;option value='2'&gt;Paladin&lt;/option&gt; &lt;option value='3'&gt;Hunter&lt;/option&gt; &lt;option value='4'&gt;Rogue&lt;/option&gt; &lt;option value='5'&gt;Priest&lt;/option&gt; &lt;option value='6'&gt;Death Knight&lt;/option&gt; &lt;option value='7'&gt;Shaman&lt;/option&gt; &lt;option value='8'&gt;Mage&lt;/option&gt; &lt;option value='9'&gt;Warlock&lt;/option&gt; &lt;option value='10'&gt;Druid&lt;/option&gt; &lt;/select&gt; </code></pre> <p>$chars: </p> <pre><code>$chars = array(0 =&gt; array("name" =&gt; "Solock", "level" =&gt; "80", "class" =&gt; "9"), 1 =&gt; array("name" =&gt; "Emmorts", "level" =&gt; "80", "class" =&gt; "3"), 2 =&gt; array("name" =&gt; "Ghom", "level" =&gt; "80", "class" =&gt; "2"), ); $json = json_encode($chars); </code></pre> <p>JSON array:</p> <pre><code>[ {"name":"Solock","level":"80","class":"9"}, {"name":"Emmorts","level":"80","class":"3"}, {"name":"Ghom","level":"80","class":"2"} ] </code></pre> <p>JSON object:</p> <pre><code>{ "0":{"name":"Solock","level":"80","class":"9"}, "1":{"name":"Emmorts","level":"80","class":"3"}, "2":{"name":"Ghom","level":"80","class":"2"} } </code></pre> <p>Is it possible, to everytime when I change [name=nick] option, other selects would select with the data from JSON object or array (if I choose "Ghom", it'd select Alliance, and Death knight)? How?</p> <p>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