Note that there are some explanatory texts on larger screens.

plurals
  1. POPopulating a <select> then changing another <select> based off the original
    primarykey
    data
    text
    <blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="https://stackoverflow.com/questions/7203860/populating-drop-down-based-on-previous-selection">Populating drop-down based on previous selection</a> </p> </blockquote> <p>Okay here's basically what I'm attempting to do. The first statement is populated by a query of a table on the server. The Second has 3 values: Elite, Core, Raider. Using AJAX and PHP I'm trying to make it so when someone selects a name from the first the second one always changes to the value that is in the database for that person; however this must remain a select in case an unoted switch happens(in which case the value of the second must be changed).</p> <pre><code>&lt;?php echo "&lt;select name='playername' onchange='filldata(this.value)'&gt;"; require("/home/a9299818/public_html/DKPTools/connect.php"); $query1 = mysql_query("SELECT player.id, player.primarytoon, player.rank, IFNULL( SUM(dkp.dkp ) , 0 ) FROM player LEFT OUTER JOIN dkp ON player.id = dkp.player_id GROUP BY player.id ORDER BY player.id"); while ($row = mysql_fetch_array($query1, MYSQL_NUM)){printf("&lt;option value='%s'&gt;%s&lt;/option&gt;",$row[0],$row[1]);} echo "&lt;/select&gt;"; echo "&lt;select name='rank'&gt;&lt;option value='1'&gt;Elite&lt;/option&gt;&lt;option value='2'&gt;Core&lt;/option&gt;&lt;option value='3'&gt;Raider&lt;/option&gt;"; ?&gt; </code></pre> <p>This PHP works and populates both selects correctly; however I'm totally lost in coding the AJAX which should change rank.value to whatever the database says it is WITHOUT REFRESHING THE PAGE.</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.
 

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