Re: selected option values not being captured by form processing software
| From: | Chris Lee | Date: | Tue, 13 Mar 2001 15:50:49 +0000 |
| Subject: | Re: selected option values not being captured by form processing software | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-43694@lists.php.net to get a copy of this message | ||
your checking the value every time you loop so that you can see if that value is checked or not. Im
sure Ive missunderstood your question... please email.
<?php
function selected($val_1, $val_2)
{
if ($val_1 == $val_2)
return ' selected ';
else
return;
}
include_once('database_class.egn');
$result = $database->select_array('', 'country', '');
echo "
<form method='post' action='$PHP_SELF'>
<select name='country'>
";
foreach($result as $pos => $val)
{
$this_country = $val['country'];
echo "
<option value='$this_country'". selected(@$country, $this_country)
..">$this_country
";
}
echo "
</select>
<input type='submit' name='done' value='Submit'>
</form>
";
?>
--
Chris Lee
Mediawaveonline.com
ph. 250.377.1095
ph. 250.376.2690
fx. 250.554.1120
lee@mediawaveonline.com
"Nicole Lallande" <mipana@mipana.com> wrote in message news:3AAE5A92.8295BE0F@mipana.com...
Hi,
Working on a code that uses a select/option field. All my other fields
are passing through to the form processing software just fine. Meloni's
PHP Essentials does this funky thing, declaring each function value as
selected or not although she shows it with the individual values not
with variable - and I don't understand why she is doing that - I don't
see it anywhere else. What I do know is whether I try her if_else
selected method or without, my value is not being passed through http.
echo "<td width=\"550\" align=\"left\"><select
name=\"select_product\">";
echo "<option value=\"\">Cat. ID No? Description Pkg Size
Price</option>";
while ($row = mysql_fetch_array($result)) {
$catid[] = $row["Cat_ID"];
}
for ($i=0; $i < sizeof($catid); $i++) {
$cat = $catid[$i];
if($select_product =="cat") {
echo "<option value=\"$cat\" selected>$cat</option>";
} else {
echo "<option value=\"$cat\">$cat</option>";
}
Thanks,
Nicole
--
########################
Nicole Lallande
nicole@nmlconsulting.com
760.753.6766
########################
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
For additional commands, e-mail: php-general-help@lists.php.net
To contact the list administrators, e-mail: php-list-admin@lists.php.net