PDA

View Full Version : Fill In Multiple Selection Boxes From One Selection Box Selection



icesolid
07-18-2007, 05:32 PM
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.


<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>

brentnicholas
07-19-2007, 08:18 PM
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.



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.


<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>