Здравствуйте! как оставить выбранное значение в селект боксе. выбрал Новосибирск что бы он и остался ? PHP: <?php$xml_city = simplexml_load_file("xml/city.xml") or die("Error: Cannot create object");if(isset($_POST['select'])) { setcookie("select",(int)$_POST['select']); $s_city = substr(htmlspecialchars(trim($_POST['select'])), 0, 100); $select[(int)$_POST['select']] = 'selected';} elseif(isset($_COOKIE["select"])) { $select[(int)$_COOKIE["select"]] = 'selected';}echo "---------".$select;echo "========".$s_city;echo "<form method=post>";if(!empty($xml_city->city->page)){ $agrs = $xml_city->city->page; echo "<select name=\"select\" onchange=\"this.form.submit()\">"; foreach ($agrs as $vals) { echo iconv('UTF-8', 'WINDOWS-1251', "<option value=$vals[ob] selected=$vals>$vals</option>"); } echo "</select></form>";}?> ХМЛЬ HTML: <?xml version="1.0" encoding="utf-8"?> <category> <city category="city"> <page ob="city">Город:</page> <page ob="moscu">Москва</page> <page ob="omsk">Омск</page> <page ob="novosib">Новосибирск</page> </city> </category>
а вот и долгожданный ответ: Жесть PHP: echo "<form method=post>";if(!empty($xml_city->city->page)){ $agrs = $xml_city->city->page; echo "<select name=\"select\" onchange=\"this.form.submit()\">"; foreach ($agrs as $vals) { $selected = '';if ($_POST['select'] == $vals[ob]) $selected = 'selected';echo "<option value=\"" . $vals[ob] . "\" " . $selected . ">" . $vals . "</option>"; //echo iconv('UTF-8', 'WINDOWS-1251', "<option value=$vals[ob].($sel1[0]).>$vals</option>"); } echo "</select></form>";}