могу скинуть скрин разметки
там того селекта нету, но в браузере он есть. Интересно почему так :-)
# UJIN (01.05.2015 / 02:58)и как мы тебе что то скажем, если ты нам кусок кода даешь?
не, там потом третий select с id='list_cafedries'
# UJIN (01.05.2015 / 02:58)просто разметка не обновилась в отладчике, то чего нет в коде, на экране тоже не будет
не, там потом третий select с id='list_cafedries'
function getPhoneDevice(vendor){
if(vendor.value!=undefined && vendor.value!=0 && vendor.value!=1){
$.ajax({
type: "POST",
url: "/ajax/get-phone-on-vendor/"+vendor.value+"/",
data: "",
cache: false
}).done (function( content ) {
var data = parseJSON(content);
if(data.total > 0){
var Insert = ['<select id="phone" placeholder="Модель смартфона" name="device1" onchange="selectDevice(this);"><option value="0">Выберите модель</option>']
for(u = 0; u < data.total; u++){
Insert.push('<option value="'+data.models[u]+'">'+data.models[u]+'</option>');
}
Insert.push('</select>');
$('#vendor').css({'display': 'none'});
$("#models").html(Insert.join()).css({'display': 'block'});
}
});
}else{
$('#models').html('').css({'display': 'none'});
if(vendor.value==1){
$('#vendor').css({'display': 'none'});
$('#my-device').val('').css({'display': 'block'});
}
}
}
function selectDevice(device) {
if(device.value!=undefined && device.value!=0){
$('#my-device').val(device.value);
$('#vendor').css({'display': 'none'});
}else{
if(device.value==0){
$('#models').html('').css({'display': 'none'});
$('#vendor').css({'display': 'block'});
}
}
}
// index
<?php
echo '<?xml version="1.0" encoding="UTF-8"?>';
$db_host = 'localhost';
$db_name = 'test';
$db_user = 'root';
$db_pass = '';
$connect = @mysql_connect($db_host, $db_user, $db_pass) or die('Error: cannot connect to database server');
@mysql_select_db($db_name) or die('Error: specified database does not exist');
@mysql_query("SET NAMES 'utf8'", $connect);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<link rel="shortcut icon" href="favicon.ico" type="image/x-icon" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="Lang" content="ru" />
<title>Koenig test menu ajax</title>
<link rel="stylesheet" href="css/css.css" type="text/css" />
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script type="text/javascript">
function cat(){
var id_cat = $('select[name="cat"]').val();
if(!id_cat){
$('div[name="podcat"]').html('');
$('div[name="firm"]').html('');
}else{
$.ajax({
type: 'POST',
url: 'base.php',
data: {action:'cat', id_cat:id_cat},
cache: false,
success: function(responce){$('div[name="podcat"]').html(responce);}
});
};
};
function firm(){
var id_podcat = $('select[name="podcat"]').val();
$.ajax({
type: 'POST',
url: 'base.php',
data: {action:'firm', id_podcat:id_podcat},
cache: false,
success: function(responce){$('div[name="firm"]').html(responce);}
});
};
</script>
</head>
<body>
<select size="1" name="cat" onchange="javascript:cat();" style="float:left;">
<option value="">Все категории</option>
<?php
$sql = mysql_query("select * from `cat`");
while($row = mysql_fetch_assoc($sql)) {
echo '<option value="' . $row['id'] . '">' . $row['name'] . '</option>' . PHP_EOL;
}
?>
</select>
<div name="podcat" style="float:left;"></div>
<div name="firm"></div>
</body>
</html>
<?php
#ini_set(default_charset,"UTF-8");
$db_host = 'localhost';
$db_name = 'test';
$db_user = 'root';
$db_pass = '';
$connect = @mysql_connect($db_host, $db_user, $db_pass) or die('Error: cannot connect to database server');
@mysql_select_db($db_name) or die('Error: specified database does not exist');
@mysql_query("SET NAMES 'utf8'", $connect);
switch ($_POST['action']){
case "cat":
echo '<select size="1" name="podcat" onchange="javascript:firm();">' . PHP_EOL;
echo '<option value="">Все подкатегории</option>' . PHP_EOL;
$sql = mysql_query("SELECT * FROM `podcat` WHERE `id_cat`=" . intval($_POST['id_cat']) . " ORDER BY `id` ASC");
while ($row = mysql_fetch_assoc($sql)) {
echo '<option value="' . $row['id_cat'] . '">' . $row['name'] . '</option>' . PHP_EOL;
};
echo '</select>' . PHP_EOL;
break;
case "firm":
echo '<div>' . PHP_EOL;
echo '<table border="1">
<tr>
<th>Name</th>
<th>Adress</th>
<th>Tel</th>
<th>Site</th>
<th>Mail</th>
</tr>';
$sql = mysql_query("SELECT * FROM `firmcat` WHERE `id_podcat`=" . intval($_POST['id_podcat']) . " ORDER BY `id` ASC");
while ($row = mysql_fetch_assoc($sql)) {
echo '<tr><td>' . $row['name'] . '</td>
<td>' . $row['adress'] . '</td>
<td>' . $row['tel'] . '</td>
<td>' . $row['site'] . '</td>
<td>' . $row['mail'] . '</td></tr>';
};
echo '</table></div>' . PHP_EOL;
break;
};
?>