Jump to content

Fill fields when user selects user from DB


eits

Recommended Posts

Hello,

 

I have a field with a selectbox which contains a list of client names and several other fields which display information from the DB.

 

I need to be able to make the fields change to the appropriate information when a user is selected from the select box.

 

Can anybody please give me an example of a bit of code that will do this?

 

Many Many Thanks in Advance!!!

Hi..

I m not sure what you wanna do.. but if that mean if some one selected whatever from selectbox that would be retain as it is afer post back.. that you want to say..? or any thing else..

if yea then that would be done via..

<?php 
while{$rs=mysql_fetch_array($result))
{
$val_from_db_loop = $rs['select_val'];
?>
<option value="<?php echo $val_from_db_loop;?>" 
          <?php if($_POST['select_box_name']==$val_from_db_loop) { ?> selected="selected" <?php } ?>
>
<?php echo $rs['select_show_val'];?>
</option>
}

 

Regards,

Vijay

I already have:

           <select name="select">
           <?php do { ?>
           <option value="<?php echo $row_conn1['clientname']?>"> <?php echo $row_conn['clientname']?></option>
           <?php
} while ($row_conn = mysql_fetch_assoc($conn));
  $rows = mysql_num_rows($conn);
  if($rows < 10) {
      mysql_data_seek($conn, 0);
  $row_conn = mysql_fetch_assoc($conn);
  }
?>
         </select>

 

to get data for the selectbox, now I just need some way of making the data in the other field I have to change when a user selects something from the selectbox. I know no javascript but am guessing the onchange is the way to go.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.