populate multiple lists

7 posts by 2 authors in: Forums > CMS Builder
Last Post: February 22, 2013   (RSS)

By nmsinc - February 17, 2013

I'm using a java based list selection that Jason had suggested about a year ago. I now need to poulate three lists based on the choice of the one below. The lists that need to be poulated are; Employee Name, Employee Group and Work Group. Any ideas?

The slection choice from the list below poulates a second list via the java populate:

<select name="member_company" onchange = "populatePayrollList(this, 'Primary');">
       <option value="">All</option>
       <?php foreach (mysql_select("member_companies", "member_type = 'Primary' ORDER BY member_company_name") as $Primary): ?>
       <option value = "<?php echo $Primary['num'];?>"><?php echo $Primary['member_company_name'];?> - <?php echo $Primary['city'];?> <?php echo $Primary['state'];?></option>
       <?php endforeach ?>
       </select>
       &nbsp;
       
       Employee Name:&nbsp;
          <select name="employee_name" id = "Primary">
          <option value="">All</option>
       </select>

See java populate below:

<?php
  require_once("../cmsAdmin/lib/viewer_functions.php");
 
  if (@$_REQUEST['target'] == "Primary") {
    $user_type = "Tech";
    $user_type2 = "Dispatcher/Tech";
    $user_type3 = "Dispatcher";
    $user_type4 = " ";
  }
  else {
    $user_type = "Tech";
    $user_type2 = "Dispatcher/Tech";
    $user_type3 = "Dispatcher";
    $user_type4 = "";
  }
  $PayRecords = mysql_select("accounts", "member_company_accounts = '".intval(@$_REQUEST['company'])."' AND disabled = 'No' AND user_type IN('$user_type', '$user_type2', '$user_type3', '$user_type4') ORDER BY fullname");
?>
<option value = "">All</option>
<?php foreach ($PayRecords as $record): ?>
  <option value = "<?php echo $record['employee_number'];?>"><?php echo $record['fullname'];?></option>
<?php endforeach ?>

nmsinc

Hi,

What is the name of the JavaScript drop down population system you are using? 

Thanks!

Greg

Greg Thomas







PHP Programmer - interactivetools.com

By nmsinc - February 18, 2013

Hi Greg,

It's a jquery coded by interactivetools. The entire script is listed in my firsrt post!

Thanks - nmsinc

nmsinc

Hi nmsinc,

In the code on your first post you have a JavaScript function called populatePayrollList that updates when a user selects something from a drop down. Do you have the JavaScript code for that function? Is this something Jason suggested in the forum? Finally, does anything need filtered out of each drop down as the user selects something? For example, if the user selects an employees name, does anything need to be filtered out of employee group when that select list is created.

Thanks!

Greg

Greg Thomas







PHP Programmer - interactivetools.com

By nmsinc - February 19, 2013

Hi Greg,

Here is the java code:

<script type = "text/javascript" src = "../cmsAdmin/3rdParty/jquery/jquery1.4.1.js"></script>

  <script type = "text/javascript">

      function populatePayrollList(company, target) {

            ajaxUrl = "populatePayrollList.php?company="+escape(company.value)+"&target="+escape(target);

            $.get(ajaxUrl, function(html){

          $('#'+target).html( html );

        });

      }

    </script>

I need to populate three lists based on the users choice of company from the “member_companies” section where field  'member_company_name' . Each user is assigned a member company, each payroll account is assigned  a member company and each contract work group is assigned a member company. When a choice is made from the company list, all three other lists must populate with only those files that match with that member company choice!

  1. List of employee names from the “accounts” section where the field ‘member_company_accounts' matches the company choice from above”.
  2. List of payroll accounting groups from the “payroll_accounts” section where the field ‘payroll_accounting_group’ matches the company choice from above.
  3. List of payroll contract groups from the “contract_work_groups” section where the field ‘assign_contract_group_id’ matches the company choice from above.

Thanks - nmsinc

nmsinc

By nmsinc - February 22, 2013

Hi Greg,

Everything worked great - thanks for the help!

nmsinc