"Ming" <minghuiyu@gmail.comwrote in message
news:bad68652-b509-4362-900d-ae4a3f75a46c@s19g2000prg.googlegroups.com...
Quote:
>I have two list box (A and B), and I have two buttons to move list
items (options)
from this box to the other.I have a submit button to submit the form.
>
I know how to move items from A to B by using Javascript, and I know
how to use <option ... selectedto select an item.
>
However, how can I select an item after the page is rendered? In other
words, A and B have been populated with data and the page is rendered.
I click the move items button to move other items from A to B. I want
all items in B are selected.
simplest break-down i could think of...
<?
$items = isset($_REQUEST['items']) ?
$_REQUEST['items'] :
array();
$myItems['A List'][] = 'Hello';
$myItems['A List'][] = 'World';
$myItems['B List'][] = 'B';
?>
<form method="post">
<?
foreach ($myItems as $type =$defined)
{
foreach ($defined as $index =$item)
{
$selected = isset($items[$type][$index]) ? 'checked' : '';
?>
<input name="items[<?= $type ?>][<?= $index ?>]"
type="checkbox"
value="<?= $item ?>"
<?= $selected ?>
Quote:
> <?= $item ?>
<br>
<?
}
}
?>
<input type="submit" value="Save And Refresh">
</form>