Quantcast
Channel: PHP Freaks: PHP Help
Viewing all articles
Browse latest Browse all 13200

Populate an arrayed dropdown when clicked

$
0
0

Hi,

 

I have a 2d array of form elements in a table, as seen here.  Among those elements are dropdown lists.  One shows college names and the other shows what degree that person has.  These are initially populated from a database with the single value pertaining to that particular record.   If they click the dropdown, I wish to populate it with all the options from that table, from which they can choose one.

 

 

Example:  User logs in and his/her record shows as an editable table row that has two dropdowns.  One dropdown shows the college they attended, and the other shows the degree they earned.  If they click the 'degree' dropdown, it populates with all the degree options contained in that particular database table - from which they can choose whatever they want.

 

I understand the database part and how to fill the dropdown with options, but I am unsure of how to know which dropdown was clicked, in that particular row, so I can fill it with options.

 

When a faculty member uses the page, he/she will only see their single record BUT when an administrator uses it they will see all the records, which they may have to edit as necessary.

 

 How do I know which dropdown has been clicked so I can populate it?

 

Here is the code where I have the dropdowns:

        foreach ($arrValues as $row){
   $id = $row['employee_id'];
   echo <<<FORM_FIELDS
            <tr>
                <td><input type="text" name="record[$id][firstName]" value="{$row['first_name']}" /></td>
                <td><input type="text" name="record[$id][lastName]" value="{$row['last_name']}" /></td>
                <td><input type="text" name="record[$id][height]" value="{$row['height']}" /></td>
                <td><input type="text" name="record[$id][cap]" value="{$row['cap']}" /></ td>
                <td><input type="text" name="record[$id][color]" value="{$row['colors']}" /></td>
              
                //shows degree type
                <td><select name="record[$id][degree]" </td> 
                <option>{$row['type']}</option> 
                </select> 
                
                //shows school attended
                <td><select name="record[$id][school]" </td> 
                <option>{$row['name']}</option> 
                </select>' 
                <td><input type="submit" name="update" value="Update" /></td>
            </tr>
FORM_FIELDS;
}

Thanks


Viewing all articles
Browse latest Browse all 13200

Trending Articles