fsf 0 Denunciar post Postado Dezembro 2, 2006 Pessoal, Como faço para selecionar um radio group com dados que vem do bd?? Compartilhar este post Link para o post Compartilhar em outros sites
Hamilcar 1 Denunciar post Postado Dezembro 2, 2006 Pessoal, Como faço para selecionar um radio group com dados que vem do bd??posta algum código pra gente ver como você está criando ou preenchendo este radio group. Compartilhar este post Link para o post Compartilhar em outros sites
fsf 0 Denunciar post Postado Dezembro 2, 2006 Quando o usuario selecioona um item na combo, esta ação gera uma busca! queria que o resultado da busca marque uma opção no radio! <html><head><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><title>Cadastrar Unidade de Saúde</title><link href="css/index.css" rel="stylesheet" type="text/css"><style type="text/css"><!--body { background-color: #E3EACE; margin-top: 14px;}--></style><script>function verifica(frm)// TRECHO JAVASCRIPT PARA VERIFICAR O CAMPO "NOME" --- INICIO// Verifica o campo NOME.{ { var str = frm.descricao.value // Verifica se foram digitados mais de 10 caracteres. if (str.length > 50) { alert("\nO campo Descrição está limitado a\n\n50 caracteres ") return false; } // Return false se o campo NOME estiver vazio. if (str == " " ) { alert("\nO campo Descrição está em branco.\n\nPor favor entre com o Descrição.") return false; } }// TRECHO JAVASCRIPT PARA VERIFICAR O CAMPO "NOME" --- FINALreturn true; }function go(){CAT = document.form.unidade.value;document.location.href='formunidadesaude.php?unidade='+ CAT;}</script></head><body><form name= "form" action="formunidadesaude.php" method="post" onSubmit="return verifica(this)" enctype="multipart/form-data" ><div name="center" align="center" ><table width="95%" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#CBD8A5" > <tr> <td height="30"><div align="right"> <label><input type="submit" name="btn_inserir" id="btn_inserir" value="Inserir" /><input type="submit" name="btn_excluir" id="btn_excluir" value="Excluir" /><input type="submit" name="btn_alterar" id="btn_alterar" value="Alterar" /><input type="submit" name="btn_limpar" id="btn_limpar" value="Limpar" /> </label></div></td> </tr></table><br> <table width="95%" border="0" cellpadding="0" cellspacing="0" bgcolor="#CBD8A5" class="bordaexterior"> <tr> <td height="30" align="right"><font face="verdana,helvetica,arial" size="1">Unidades:</font></td> <td height="30"><select name="unidade" id="unidades" onChange="go();" > <?php include "Connections/conexao.php"; $query = "select codunidadesaude,descricao from tb_unidadesaude order by descricao"; $resposta= pg_query("$query"); while ($dados=pg_fetch_array($resposta)) { if ($_GET['unidade'] == $dados['codunidadesaude']) { $selected = 'selected'; $ha = 1; } else { $selected=''; } $saida .= '<option value="'.$dados['codunidadesaude'].'" '.$selected.'>'.$dados['descricao'].'</option>'; } echo '<option '.(($ha)?'':'selected').'>Selecione um nome</option>'.$saida; ?> </select></td> </tr> <tr> <td height="30" align="right"> </td> <td height="30"><label></label></td> </tr> <tr> <td height="30" align="right"><font face="verdana,helvetica,arial" size="1">Descrição:</font></td> <td height="30"><label> <input name="descricao" type="text" class="campoform" id="descricao" size="50" maxlength="50" value ="<?php include "Connections/conexao.php"; $codigo = $_GET[unidade]; $sql1="select descricao,municipal,fazexame from tb_unidadesaude where codunidadesaude=" . $_GET['unidade']; if($codigo == ''){ }else{ $respos= pg_query("$sql1"); while ($dados3=pg_fetch_array($respos)){ echo $dados3["descricao"]; $aux =$dados3["fazexame"]; } } ?> "> </label></td> </tr> <tr> <td height="30" align="right"><font size="1" face="verdana,helvetica,arial">Unidade Municipal? </font></td> <td height="30" valign="middle"><label><input type="radio" name="unidademunicipal" value="Sim"> <font face="verdana,helvetica,arial" size="1">Sim</font></label> <label><input type="radio" name="unidademunicipal" value="Não"> <font size="1" face="verdana,helvetica,arial">Não</font> </label></td> </tr> <tr> <td height="30" align="right" ><font face="verdana,helvetica,arial" size="1">Faz Exames?</font></td> <td height="30" ><label><input type="radio" name="fazexame" value="Sim" <?php echo $aux == 'Sim' ? "checked=\"checked\"" : "";?>><font face="verdana,helvetica,arial" size="1"> Sim</font></label> <label><input type="radio" name="fazexame" value="Não" <?php echo $aux == 'Não' ? "checked=\"checked\"" : "";?>><font face="verdana,helvetica,arial" size="1">Não</font></label></td> </tr> <tr> <td height="30"></td> <td height="30"><input type="hidden" name="ResponsavelCadastro"> <input type="hidden" name="DataHoraCadastro"></td> </tr> <?php //alterando um paciente function alterar($nome,$crm,$codmedico) { }//incluindo um pacientefunction incluir($descricao,$unidademunicipal,$fazexame) { // Conexão com o Banco de Dados e o Database "sigex" include "Connections/conexao.php"; $query = "insert into tb_unidadesaude(descricao,municipal,fazexame) values ('$descricao','$unidademunicipal','$fazexame')"; $result = pg_query($query); if($result){ echo '<script>alert("\nCadastro efetuado com socesso!") </script>'; echo "<meta HTTP-EQUIV='refresh' CONTENT='1;URL=formunidadesaude.php'>"; } pg_close(); }//excluindo um pacientefunction excluir() { // Conexão com o Banco de Dados e o Database "sigex" }if ($_POST) { if ($_POST['btn_inserir']) { incluir($_POST['descricao'],$_POST['unidademunicipal'],$_POST['fazexame']); echo $data; } elseif ($_POST['btn_alterar']) { alterar(); } elseif ($_POST['btn_excluir']) { excluir(); } elseif ($_POST['btn_limpar']) { } } ?></table></div></form></body></html> Compartilhar este post Link para o post Compartilhar em outros sites
Marcio Leandro 0 Denunciar post Postado Dezembro 2, 2006 <input type="radio" checked /> Compartilhar este post Link para o post Compartilhar em outros sites
fsf 0 Denunciar post Postado Dezembro 3, 2006 To fazendo assim: <label><input type="radio" name="fazexame" value="Não" <?php echo $aux == 'Não' ? "checked=\"checked\"" : "";?>>Mas não tá funcionando! Compartilhar este post Link para o post Compartilhar em outros sites
Hamilcar 1 Denunciar post Postado Dezembro 4, 2006 Quando o usuario selecioona um item na combo, esta ação gera uma busca! queria que o resultado da busca marque uma opção no radio! <html><head><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><title>Cadastrar Unidade de Saúde</title><link href="css/index.css" rel="stylesheet" type="text/css"><style type="text/css"><!--body { background-color: #E3EACE; margin-top: 14px;}--></style><script>function verifica(frm)// TRECHO JAVASCRIPT PARA VERIFICAR O CAMPO "NOME" --- INICIO// Verifica o campo NOME.{ { var str = frm.descricao.value // Verifica se foram digitados mais de 10 caracteres. if (str.length > 50) { alert("\nO campo Descrição está limitado a\n\n50 caracteres ") return false; } // Return false se o campo NOME estiver vazio. if (str == " " ) { alert("\nO campo Descrição está em branco.\n\nPor favor entre com o Descrição.") return false; } }// TRECHO JAVASCRIPT PARA VERIFICAR O CAMPO "NOME" --- FINALreturn true; }function go(){CAT = document.form.unidade.value;document.location.href='formunidadesaude.php?unidade='+ CAT;}</script></head><body><form name= "form" action="formunidadesaude.php" method="post" onSubmit="return verifica(this)" enctype="multipart/form-data" ><div name="center" align="center" ><table width="95%" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#CBD8A5" > <tr> <td height="30"><div align="right"> <label><input type="submit" name="btn_inserir" id="btn_inserir" value="Inserir" /><input type="submit" name="btn_excluir" id="btn_excluir" value="Excluir" /><input type="submit" name="btn_alterar" id="btn_alterar" value="Alterar" /><input type="submit" name="btn_limpar" id="btn_limpar" value="Limpar" /> </label></div></td> </tr></table><br> <table width="95%" border="0" cellpadding="0" cellspacing="0" bgcolor="#CBD8A5" class="bordaexterior"> <tr> <td height="30" align="right"><font face="verdana,helvetica,arial" size="1">Unidades:</font></td> <td height="30"><select name="unidade" id="unidades" onChange="go();" > <?php include "Connections/conexao.php"; $query = "select codunidadesaude,descricao from tb_unidadesaude order by descricao"; $resposta= pg_query("$query"); while ($dados=pg_fetch_array($resposta)) { if ($_GET['unidade'] == $dados['codunidadesaude']) { $selected = 'selected'; $ha = 1; } else { $selected=''; } $saida .= '<option value="'.$dados['codunidadesaude'].'" '.$selected.'>'.$dados['descricao'].'</option>'; } echo '<option '.(($ha)?'':'selected').'>Selecione um nome</option>'.$saida; ?> </select></td> </tr> <tr> <td height="30" align="right"> </td> <td height="30"><label></label></td> </tr> <tr> <td height="30" align="right"><font face="verdana,helvetica,arial" size="1">Descrição:</font></td> <td height="30"><label> <input name="descricao" type="text" class="campoform" id="descricao" size="50" maxlength="50" value ="<?php include "Connections/conexao.php"; $codigo = $_GET[unidade]; $sql1="select descricao,municipal,fazexame from tb_unidadesaude where codunidadesaude=" . $_GET['unidade']; if($codigo == ''){ }else{ $respos= pg_query("$sql1"); while ($dados3=pg_fetch_array($respos)){ echo $dados3["descricao"]; $aux =$dados3["fazexame"]; } } ?> "> </label></td> </tr> <tr> <td height="30" align="right"><font size="1" face="verdana,helvetica,arial">Unidade Municipal? </font></td> <td height="30" valign="middle"><label><input type="radio" name="unidademunicipal" value="Sim"> <font face="verdana,helvetica,arial" size="1">Sim</font></label> <label><input type="radio" name="unidademunicipal" value="Não"> <font size="1" face="verdana,helvetica,arial">Não</font> </label></td> </tr> <tr> <td height="30" align="right" ><font face="verdana,helvetica,arial" size="1">Faz Exames?</font></td> <td height="30" ><label><input type="radio" name="fazexame" value="Sim" <?php echo $aux == 'Sim' ? "checked=\"checked\"" : "";?>><font face="verdana,helvetica,arial" size="1"> Sim</font></label> <label><input type="radio" name="fazexame" value="Não" <?php echo $aux == 'Não' ? "checked=\"checked\"" : "";?>><font face="verdana,helvetica,arial" size="1">Não</font></label></td> </tr> <tr> <td height="30"></td> <td height="30"><input type="hidden" name="ResponsavelCadastro"> <input type="hidden" name="DataHoraCadastro"></td> </tr> <?php //alterando um paciente function alterar($nome,$crm,$codmedico) { }//incluindo um pacientefunction incluir($descricao,$unidademunicipal,$fazexame) { // Conexão com o Banco de Dados e o Database "sigex" include "Connections/conexao.php"; $query = "insert into tb_unidadesaude(descricao,municipal,fazexame) values ('$descricao','$unidademunicipal','$fazexame')"; $result = pg_query($query); if($result){ echo '<script>alert("\nCadastro efetuado com socesso!") </script>'; echo "<meta HTTP-EQUIV='refresh' CONTENT='1;URL=formunidadesaude.php'>"; } pg_close(); }//excluindo um pacientefunction excluir() { // Conexão com o Banco de Dados e o Database "sigex" }if ($_POST) { if ($_POST['btn_inserir']) { incluir($_POST['descricao'],$_POST['unidademunicipal'],$_POST['fazexame']); echo $data; } elseif ($_POST['btn_alterar']) { alterar(); } elseif ($_POST['btn_excluir']) { excluir(); } elseif ($_POST['btn_limpar']) { } } ?></table></div></form></body></html> Tenta colocar assim:<label> <input type="radio" name="RadioGroup1" <?php echo $aux == 'Não' ? 'checked="checked"' : '';?> value="radio" /> Não</label> <br /><label> <input type="radio" name="RadioGroup1" <?php echo $aux == 'Sim' ? 'checked="checked"' : '';?> value="radio" /> Sim</label> Compartilhar este post Link para o post Compartilhar em outros sites
fsf 0 Denunciar post Postado Dezembro 4, 2006 Não funcionou não!!! veja o codigo: <td height="30" ><label><input type="radio" name="fazexame" <?php echo $aux == 'Sim' ? 'checked="checked"' : '';?>value="radio" /> Sim<font face="verdana,helvetica,arial" size="1"> Sim</font></label> <label><input type="radio" name="fazexame" <?php echo $aux == 'Não' ? 'checked="checked"' : '';?>value="radio" /> Não<font face="verdana,helvetica,arial" size="1">Não</font></label></td> Compartilhar este post Link para o post Compartilhar em outros sites
Hamilcar 1 Denunciar post Postado Dezembro 4, 2006 Não funcionou não!!!veja o codigo: <td height="30" ><label><input type="radio" name="fazexame" <?php echo $aux == 'Sim' ? 'checked="checked"' : '';?>value="radio" /> Sim<font face="verdana,helvetica,arial" size="1"> Sim</font></label> <label><input type="radio" name="fazexame" <?php echo $aux == 'Não' ? 'checked="checked"' : '';?>value="radio" /> Não<font face="verdana,helvetica,arial" size="1">Não</font></label></td> Cara quando postei tinha feito um teste aqui e tinha funcionado, verifique se esta variável $aux está recebendo um valor e qual este valor. Compartilhar este post Link para o post Compartilhar em outros sites
fsf 0 Denunciar post Postado Dezembro 4, 2006 A variávrl $aux esta recebendo valor! O valor impresso no form é: Sim Compartilhar este post Link para o post Compartilhar em outros sites
Hamilcar 1 Denunciar post Postado Dezembro 4, 2006 A variávrl $aux esta recebendo valor! O valor impresso no form é: SimOla, não sei o que pode estar acontecendo, talvez um espaço em branco no início ou no fim do valor de $aux, testei aqui e deu certo, tenta colocar um trim($aux), pra ver. Abaixo o código que testei aqui e funcionou<!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><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /><title>Teste</title></head><body><?php $aux = 'Sim'; $aux = trim($aux); ?><form id="form1" name="form1" method="post" action=""> <p> <label> <input type="radio" name="fazexame" value="radio" <?php echo $aux == 'Sim' ? 'checked="checked"' : '';?>/> Sim </label> <br /> <label> <input type="radio" name="fazexame" value="radio" <?php echo $aux == 'Não' ? 'checked="checked"' : '';?>/> Não </label> <br /> </p></form></body></html> Compartilhar este post Link para o post Compartilhar em outros sites
fsf 0 Denunciar post Postado Dezembro 5, 2006 Funcionou!! Coloquei o trim!!!!Mas!!Qual é a função do trim??Obrigado pela ajuda!! Compartilhar este post Link para o post Compartilhar em outros sites
Hamilcar 1 Denunciar post Postado Dezembro 5, 2006 Funcionou!! Coloquei o trim!!!!Mas!!Qual é a função do trim??Obrigado pela ajuda!!a função do trim é de tirar espaços em branco do início e do final de uma string. Compartilhar este post Link para o post Compartilhar em outros sites