1

I have been trying to figure out a piece of code to answer the following question.

I have a ticketing site that has a dropdown that users select what departement they want their ticket to go to, I need it to populate the text area with a few things (asking them to include their id, location, supervisor etc)

My code for the dropdown is:

     </tr>
<tr height=2px><td align="left" colspan=2 >&nbsp;</td</tr>
<tr>
    <th>Department:</th>
    <td>
        <select name="deptId" onChange="getTopic('findtopic.php?topic_id='+this.value)">
            <option value="" selected >Select Department</option>
            <?
             $services= db_query('SELECT dept_id,dept_name FROM '.DEPT_TABLE.' ORDER BY dept_name');
             while (list($deptId,$dept) = db_fetch_row($services)){
                $selected = ($info['deptId']==$deptId)?'selected':''; ?>
                <option value="<?=$deptId?>"<?=$selected?>><?=$dept?></option>
            <?
             }?>
        </select>
        &nbsp;<font class="error"><b>*</b>&nbsp;<?=$errors['deptId']?></font>
    </td>
</tr>

The code for the text area is:

    <tr>
    <th valign="top">Message:</th>
    <td>
        <? if($errors['message']) {?> <font class="error"><b>&nbsp;<?=$errors['message']?></b></font><br/><?}?>
        <textarea name="message" cols="35" rows="8" wrap="soft" style="width:85%"><?=$info['message']?></textarea>
    </td>
</tr>

My hope is that I can set something in motion so when a user selects a "access requests" from the dropdown (which in the mysql db is "9" in the depts list) that the text area will auto populate with a list of things required of the users.

I am brand new to coding and got the site up and running (with a load of help from OSTICKET forums) but am stumped by this one.

If you need any other data, let me know.

fireballbrady

  • You don't have any escaping in place anywhere. This is insecure! Please add htmlspecialchars() to every variable that is output into HTML. – Sven Oct 03 '12 at 23:28
  • 1
    This is impossible to do with just PHP and HTML. You will need to look into Javascript, probably easiest if you look into JQuery, and AJAX. – Justin Wood Oct 03 '12 at 23:29
  • I believe that you can do it using any of the following Javascript/Ajax/Jquery... You can site see this site with simple running codes if you want to apply your desired answer in your project. http://www.w3schools.com/php/php_ajax_database.asp – Clint Bugs Oct 04 '12 at 00:40

0 Answers0