Usamos cookies para medir audiência e melhorar sua experiência. Você pode aceitar ou recusar a qualquer momento. Veja sobre o iMasters.
em um sistema para vender imoveis
primeiro:
escolher se é pra venda ou locação
segundo:
ao escolher, ele me mostra os tipo de imoveis disponíveis para a opção, ou seja se você escolher venda, vai mostrar os imoveis (apartamento, casa, ...) disponíveis para venda), até ai tudo certo
terceiro:
ao escolher o imóvel, ele me mostra se está em bairro, condomínio ou ambos, ai que está o problema, não consigo fazer aparecer
código do formulário
<form action="cliente.php" method='post' name='cliente' >
<fieldset style='width:30%; float:left; height:130px'>
<div align="center">Venda ou Locação?<br />
<table>
<tr>
<td><input type='radio' name='venda_loc' value='venda' id='venda' onclick="validar()" ></td>
<td>Venda</td>
</tr>
<tr>
<td><input type='radio' name='venda_loc' id='loc' value='locacao' onclick="validar()"/></td>
<td>Locação</td>
</tr>
</table>
</div><!-- div venda_loc -->
</fieldset><!-- fieldset venda_loc -->
<fieldset style='width:30%; float:left;height:130px'>
<div align="center" >Tipo do Imóvel?
<div id='imovel'>
</div><!-- div imovel -->
</div><!-- div imovel -->
</fieldset><!-- fieldset imovel -->
<fieldset style='width:30%; float:left; height:130px'>
<div align='center'>Bairro ou Condomínio?
<div id='bairro'>
</div><!-- div bairro_cond -->
</div><!-- div bairro/condominio -->
</fieldset><!-- fieldset bairro/condominio -->
</form>
função para fazer aparecer os imoveis
function validar(){
if (document.getElementById('venda').checked == true){
var venda_loc = document.getElementById('venda').value;
}// se venda estiver selecionado
if (document.getElementById('loc').checked == true){
var venda_loc = document.getElementById('loc').value;
}// se locacao estiver selecionado
if (venda_loc == 'venda'){
imovel.innerHTML = '<table>'+
<?php
$sql = mysql_query("select distinct(imovel) from cadastrar_imovel where venda_loc='venda' order by imovel");
while ($row = mysql_fetch_row($sql)) {
?>
'<tr><td><input type="radio" name="imovel" id="<?php echo $row[0];?>" onclick="validar2()" value="<?php echo $row[0];?>"><?php echo $row[0];?></td></tr>'+
<?php
}//fim while
?>
'</table>';
}// se venda_loc for igual a venda
if (venda_loc == 'locacao'){
imovel.innerHTML =
<?php
$sql = mysql_query("select distinct(imovel) from cadastrar_imovel where venda_loc='locacao' order by imovel");
while ($row = mysql_fetch_row($sql)){
?>
'<input type="radio" name="imovel" id="<?php echo $row[0];?>" onclick="validar2()" value="<?php echo $row[0];?>"><?php echo $row[0];?>'+
<?php
}// fim while
?>
'</table>';
} // se venda_loc for igual a locacao
}// function validar
função para fazer aparecer se é bairro ou condominio
function validar2(){
if (document.getElementById('apartamento').checked == true){
var imovel = document.getElementById('apartamento').value;
}// se aparatamento estiver selecionado
if (document.getElementById('casa').checked == true){
var imovel = document.getElementById('casa').value;
}// se casa estiver selecionado
if (document.getElementById('terreno_lote').checked == true){
var imovel = document.getElementById('terreno_lote').value;
}// se terreno_lote estiver selecionado
if (document.getElementById('galpao_loja_sala').checked == true){
var imovel = document.getElementById('galpao_loja_sala').value;
}// se galpao_loja_sala estiver selecionado
if (document.getElementById('sitio_chac_faz').checked == true){
var imovel = document.getElementById('sitio_chac_faz').value;
}// se sitio_chacara_fazenda estiver selecionado
if (imovel == 'apartamento'){
alert('teste');
}
}// function validar2
alguém tem ideia de como resolver?Carregando comentários...