Jump to content

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.