Usamos cookies para medir audiência e melhorar sua experiência. Você pode aceitar ou recusar a qualquer momento. Veja sobre o iMasters.
Alguém poderia me ajudar com esse script quando seleciono a categoria no 1 select no 2 select aparece para selecionar o post quando seleciono o post é para listar o titulo e o texto do post mais aparece a mensagem erro ao selecionar o post. Vou está postando os código para ver se vcs pode me ajudar.
<!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">
<head>
<?php include"conexao.php"; ?>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Combo Dinamico</title>
<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript">
$(function(){
$("select[name=categoria]").change(function(){
beforeSend:$("select[name=post]").html('<option value="0">Aguarde carregando...</option>');
var categoria = $("select[name=categoria]").val();
$.post("categoria.php",{categoria:categoria},function(pega_categoria){
complete:$("select[name=post]").html(pega_categoria);
$("select[name=post]").change(function(){
beforeSend:$("#single_div").show("slow").html('<h2>Aguarde carregando...</h2>');
var post = $("select[name_post]")
.val();
$.post("post.php",{post:post},function(pega_post){
complete:$("#single_div").hide("slow");
$("#single").show("slow").html(pega_post);
})
})
})
})
})
</script>
</head>
<body>
<form name="cat_form" method="post" action="">
<select name="categoria">
<option value="0">Selecione uma categoria</option>
<?php
$pega_categoria = mysql_query("SELECT * FROM categoria");while($res = mysql_fetch_array($pega_categoria)){
$cat_id = $res['cat_id'];
$cat_name = $res['cat_name'];
echo'<option value="'.$cat_id.'">'.$cat_name.'</option>';
}
}
?>
</select>
</form>
<form name="post_form" method="post" action="">
<select name="post">
<option value="0" disabled="disabled">Antes selecione a categoria</option>
</select>
</form>
<div id="single_div" style="display:none">
</div>
<div id="single" style="display:none">
</div>
</body>
</html>
<?php include"conexao.php"; ?>
<?php
$minha_categoria = $_POST['categoria'];
$seleciona_categoria = mysql_query("SELECT * FROM posts WHERE cat_id = '$minha_categoria'");echo '<option value="sem post nesta categoria"></option>';$post_id = $res_cat['post_id'];
$titulo = $res_cat['titulo'];
echo '<option value="'.$post_id.'">'.$titulo.'</option>';
}
}
?>
<?php include"conexao.php"; ?>
<?php
$meu_post = $_POST['posts'];
$seleciona_post = mysql_query("SELECT * FROM posts WHERE post_id = '$meu_post'");$titulo = $res_post ['titulo'];
$texto = $res_post ['texto'];
echo '<h1>'.$titulo.'</h1><p>'.$texto.'</p>';
}
}
?>Carregando comentários...