Jump to content
php.lv forumi

Formas.. formas..


Ugabuga

Recommended Posts

aa..

 

<select name="selectliste"><?php
switch ($_POST['selectliste']) {
case 'pirmais':
echo "<option value=\"pirmais\" selected=\"selected\">variants 1</option>\n<option value=\"otrais\">variants 2</option>";
case 'otrais':
echo "<option value=\"pirmais\">variants 1</option>\n<option value=\"otrais\" selected=\"selected\">variants 2</option>";
}
?></select>

 

nu tas tā.. diezgan primitīvā rakstā..

Edited by php_Stopp
Link to comment
Share on other sites

var jau arī kaukā šitā..:

 

<?php
switch($_POST['selectliste']) {
case 'pirmais':
$1st_value = ' selected="selected"';
case 'otrais':
$2nd_value = ' selected="selected"';
}
?>
<select name="selectliste">
<option value="pirmais"<? echo (isset($1st_value) ? $1st_value : ''); ?>>1. variants</option>
<option value="otrais"<? echo (isset($2nd_value) ? $2nd_value : ''); ?>>2. variants</option></select>

 

tas ar tā, uz ātru roku..

Edited by php_Stopp
Link to comment
Share on other sites

vaij šitā

$_POST['selectliste'] = (isset($_POST['selectliste']))?$_POST['selectliste']:false;
$values = array(
 'pirmais' => '1. variants',
 'otrais' => '2. variants',
 'daudzais' => 'n. variants'
);
echo '<select>';
foreach($values as $value => $label)
 echo '<option value="'.$value.'"'.( ($_POST['selectliste'] == $value)?' selected="selected"':'').'>'.$label.'</option>';
echo '</select>';

Link to comment
Share on other sites

×
×
  • Create New...