Question: Repopulating form parameters
| From: | Stuart Felenstein | Date: | Sat, 11 Dec 2004 11:48:05 +0000 |
| Subject: | Question: Repopulating form parameters | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-204046@lists.php.net to get a copy of this message | ||
I'm hoping that this question will be more succinct.
I am trying to repopulate a search form with a user's
chosen paramters. I am running into a problem with
"multiple select lists"
First , this is the element when the form is first
presented to the user:
<select name="Ind[]" size="8" multiple="multiple"
id="Ind[]" >
<?php while($row = mysql_fetch_array($inds,
YSQL_BOTH)) { echo '<option
value="'.$row['CareerIDs'].'">'.$row['CareerCategories'].'</option>';
}
?>
So the element's option are taken from a table.
Now I am grabbing the array and can print out the
chosen values correctly, either using an implode:
if (count($Ind) > 0 AND is_array($Ind)) {
$Ind = "'".implode("','", $Ind)."'";
}
or a "for" loop:
if (isset($Ind)) {
$j = count($Ind);
for($i=0; $i<$j; $i++)
print_r($Ind[$i]);
}
What I can't do is getting the options that were
chosen to be highlighted in the select list.
i.e if there are 5 options for user to choose from:
1-Banking 2-Arts 3-I.T. 4-Accounting 5-Retail
And user chooses 1-Banking and 5-Retail, when I
reapply the query string I want those 2 to be
highlighed in the options list.
It is working fine for textfield.
?Ind%5B%5D=1&Ind%5B%5D=2&JTitle=&City=Bronx&Days=&Recs=15&Submit=Submit
If I apply the above query string, Bronx will be
populated in the City<textfield>
Not so, with the Ind[] array.
Anyone know what I am talking about ?
Stuart