Forums

Auto populate fields in a PHP form with a Drop down selection

mister_syafiq 24 Sep, 2014
hey guys!🙂
im new here and new in php. Im using adobe dreamweaver and phpmyadmin. So if anyone can help me through this problem, i really appreciate it.

So this is my problem. I already make a drop down selection in my form and connected to my database which is MyphpAdmin.
All data are viewed. The problem is i want to make when i click on one of data in the drop down menu,then on the other field,
will generate other data from same table but different column. For example,i have a
database name = "Test"
table ="Select"
column 1 = "id"
column 2 = "name"
column 3 = "address"

so in the select menu, there will be all "id", then above the select menu, there will be field for "name" and "address". So i want when i click on any "id" in the select menu, then on the "name" and "address" field, there will generate what data that link on that "id".

I really hope someone expert in this matter may help me. 😀
edshira 27 Oct, 2014
Hi mistersyafiq, sorry for the late response. I just found your thread.
Actually, I've the same problem recently but luckily I already found the solution. 🙂

What you do need id - dynamic dropdown menu. Which is, it will dynamically list down all the details you need to.
But first, you need to understand what and how dropdown menu / selection list be functional.

<select name = "dropdown">
              <option value = "value name">Default</option>
          </select>


To make it turn to 'dynamic', you have to put some php code in "value name" and "Default"

Example :

<select name = "dropdown">
   <option value="Option"> -- Please choose one ID --</option>
    <?php
             $getData = mysql_query("SELECT * FROM detail ORDER BY name ASC");
     while($row = mysql_fetch_assoc($getData)){
     ?>
    <option value="<?php echo $row['id']; ?>">
              <?php echo $row['name']; ?>
     </option>
     <?php
      }
      ?>
      </select>



But please make sure you already set up the action script.
And sorry for my bad English.
Max_admin 28 Oct, 2014
Actually Chronoforms has the "Dynamic data" feature for dropdowns which should solve the first part, the 2nd part requires setting up an "Event" for the dropdown, so it can execute an AJAX call and either publish the fields with values or replaces them, the next update should have a new dynamic HTML AJAX feature to replace HTML

Regards,
Max
Max
ChronoForms developer...
Did you try ChronoMyAdmin for managing your Joomla database tables ?
This topic is locked and no more replies can be posted.