Results 1 to 2 of 2

Thread: Fill In Multiple Selection Boxes From One Selection Box Selection

  1. #1
    Join Date
    Mar 2006
    Location
    Buffalo, NY
    Posts
    15
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Fill In Multiple Selection Boxes From One Selection Box Selection

    I have a selection box at the top of my web site and then I have a bunch of rows printed out into a table from a MySQL database below that selection box.

    Each one of these rows has a selection box in the first column.

    I want the selection box that is at the top of all of these rows of data to fill the same value in as it if I select a value from it.

    So if I select "Apples" from the selection box at the top of the table of data rows then all of the selection boxes in the table below would fill in with Apples.

    Here is the code that each one of the selection boxes in the table has.

    PHP Code:
    <select name="inspector[<?php echo $row["id"]; ?>]" class="smallInput">
    <option value=""></option>
    <?php
    $result1 
    mysql_query("SELECT * FROM users WHERE account_type='Inspector' ORDER BY username ASC");

    while(
    $row1 mysql_fetch_array($result1)) {
    ?>
      <option value="<?php echo $row1["user_code"]; ?>"><?php echo $row1["username"]; ?></option>
    <?php
    }
    ?>
    </select>
    Last edited by icesolid; 07-18-2007 at 05:55 PM.

  2. #2
    Join Date
    Jan 2007
    Posts
    51
    Thanks
    2
    Thanked 3 Times in 3 Posts

    Default

    You need a function to loop over all of your select boxes in the form (testing each one's name).
    then for each one, loop over it's contents inspecting each option looking for 'apple'. And set it as that selectedIndex.


    Quote Originally Posted by icesolid View Post
    I have a selection box at the top of my web site and then I have a bunch of rows printed out into a table from a MySQL database below that selection box.

    Each one of these rows has a selection box in the first column.

    I want the selection box that is at the top of all of these rows of data to fill the same value in as it if I select a value from it.

    So if I select "Apples" from the selection box at the top of the table of data rows then all of the selection boxes in the table below would fill in with Apples.

    Here is the code that each one of the selection boxes in the table has.

    PHP Code:
    <select name="inspector[<?php echo $row["id"]; ?>]" class="smallInput">
    <option value=""></option>
    <?php
    $result1 
    mysql_query("SELECT * FROM users WHERE account_type='Inspector' ORDER BY username ASC");

    while(
    $row1 mysql_fetch_array($result1)) {
    ?>
      <option value="<?php echo $row1["user_code"]; ?>"><?php echo $row1["username"]; ?></option>
    <?php
    }
    ?>
    </select>

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •