Forums

how to fill my form with data from another table

andelumut 29 Apr, 2010
I have chronoforms' form, i need to fill some textbox and list with data from another table

can anyone help me?
ozneilau 21 May, 2010
Hi Andelumut,

There are already a few examples in the forums that might show you the way:

http://chronoengine.com/forums/index.php?option=com_chronoforums&cont=posts&f=2&t=4517
http://chronoengine.com/forums/index.php?option=com_chronoforums&cont=posts&f=2&t=10926
http://chronoengine.com/forums/index.php?option=com_chronoforums&cont=posts&f=5&t=16862

Based on the examples, I was able to populate a drop down list from another table using the following amended code in my form:

Original Code:
<div class="form_item">
  <div class="form_element cf_dropdown">
    <label class="cf_label" style="width: 150px;">Representative:</label>
    <select class="cf_inputbox" id="select_23" size="1" title=""  name="Rep">
    <option value="">Choose Option</option>

    <option value="Ross">Ross</option>
    <option value="Kevin">Kevin</option>
    <option value="Jan">Jan</option>
    <option value="Bob">Bob</option>
    <option value="Julianne">Julianne</option>

    </select>
  </div>
  <div class="cfclear"> </div>
</div>


Amended Code:
<div class="form_item">
  <div class="form_element cf_dropdown">
    <label class="cf_label" style="width: 150px;">Representative:</label>
    <select class="cf_inputbox" id="select_23" size="1" title=""  name="Rep">
    <option value="">Choose Option</option>

    <?php
      jimport( 'joomla.application.component.controller' );
      global $mainframe;
      $database =& JFactory::getDBO();
      $database->setQuery("SELECT RepFirstName FROM ou9g_chronoforms_Reps ORDER BY RepFirstName");
      $cconnections = $database->loadObjectList();
      foreach($cconnections as $cconnection){
        echo "<option value=\"" . $cconnection->RepFirstName . "\">" . $cconnection->RepFirstName . "</option>\n";
      }
    ?>

    </select>
  </div>
  <div class="cfclear"> </div>
</div>


I hope this helps,

Neil
This topic is locked and no more replies can be posted.