Note that there are some explanatory texts on larger screens.

plurals
  1. POediting html using javascript that calls php function that gets information from sql database.. complicated...
    text
    copied!<p>i am trying to edit a select list every time the list before it is being changed. what i am trying to do is change the list already existing into another list, called by a php function, that generates a list of the new information it has from the first list and an sql database.</p> <p>it's pretty hard to explain so here is my code:</p> <p>the base of my code</p> <pre><code>//php &amp; html .... $cli = lastNameList(); //first list $tli = firstNameList(); //second list echo" $cli &lt;div id='editHtml'&gt;$tli&lt;/div&gt; "; .... </code></pre> <p>functions (php)</p> <pre><code>//the functions function lastNameList(){ $options="&lt;select id='lastNames'&gt;"; $sql="SELECT * FROM lastName"; $result=mysql_query($sql); $options.="&lt;option value='blank'&gt;-- last names --&lt;/option&gt;" ; while ($row=mysql_fetch_array($result)) { $name=$row["name"]; $options.="&lt;option value='$name'&gt;$name&lt;/option&gt;"; } $options.= "&lt;/SELECT&gt;"; return "$options"; } function firstNameList(){ $options="&lt;select id='firstNames' style='margin-right:40px;'&gt;"; </code></pre> <p>having a problem over here:</p> <pre><code>$sql="SELECT DISTINCT Name FROM firstName WHERE LastName ='lastNameSelectedGoesHere'"; //how do i get the value of the last name so i could make a query for it? //using distinct to make sure there are no duplicates $result=mysql_query($sql); $options.="&lt;option value='blank'&gt;-- first name --&lt;/option&gt;" ; while ($row=mysql_fetch_array($result)) { $name=$row["Name"]; $options.="&lt;option value='$name'&gt;$name&lt;/option&gt;"; } $options.= "&lt;/SELECT&gt;"; return "$options"; } </code></pre> <p>js (inside a php file if it matters)</p> <pre><code>echo" &lt;script type='text/javascript'&gt; $('#lastNames').change(function() { document.getElementById('eTech').innerHTML="; $ll = firstNameList(); echo"$ll; });"; </code></pre> <p>so as you can see my js file is in a php file, it does work, what i tried to do there, is generate a new first name list to come and replace the old one but i failed... anyone has an answer or suggestion to what i should do?</p>
 

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