
Ajuda Com Formulario 2
#1
Posted 20/01/2011, 15:15
Tem alguma maneira de eu pegar o valor de um campo hidden e atribuir a uma variavel sem eu ter executado o formulario?.
Alguem pode me ajudar?
#2
Posted 20/01/2011, 19:14
Boa tarde galera,
Tem alguma maneira de eu pegar o valor de um campo hidden e atribuir a uma variavel sem eu ter executado o formulario?.
Alguem pode me ajudar?
Acho que não, pois se você não enviar as informações como que ele vai conseguir elas? Mais pra que você quer mesmo fazer isso? Me explique melhor, talvez eu possa lhe ajudar.
Abraços,
bigCheat.
#3
Posted 21/01/2011, 08:58
Boa tarde galera,
Tem alguma maneira de eu pegar o valor de um campo hidden e atribuir a uma variavel sem eu ter executado o formulario?.
Alguem pode me ajudar?
Acho que não, pois se você não enviar as informações como que ele vai conseguir elas? Mais pra que você quer mesmo fazer isso? Me explique melhor, talvez eu possa lhe ajudar.
Abraços,
bigCheat.
Em primeiro lugar obrigado pela disposição de ajudar!, seguinte tenho um form e nele tenho um campo convenio ao lado do campo tem um botão que quando clicado abre um poup-up com a listagem de todos os convenios cadastrados o usuario escolhe, e o nome e id do convenio escolhido vão para os campos text-field e hidden respectivamente do form pai, quero pegar o valor do campo hidden na hora que o usuario escolhe o convenio desejado para com o id poder saber se o convenio exige o campo matricula e num. de guia e assim deixar os campos habilitados ou não.
form.php
<!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=utf-8" /> <script type="text/javascript"> function abre_conv(){ window.open('form_busca_conv.php', 'fornruq1w2w', 'top=110, left=110, width=480, height=395'); } </script> <title>Untitled Document</title> </head> <body> <table width="776" border="0" cellspacing="4" cellpadding="0"> <tr> <td> </td> <td colspan="2">Convênio:<input type="hidden" name="hf_agendamento_paciente_convenio" id="hf_agendamento_paciente_convenio"/></td> <td>Matrícula:</td> <td>Nro Guia:</td> </tr> <tr> <td> </td> <td colspan="2"><input name="tf_agendamento_paciente_convenio" type="text" id="tf_agendamento_paciente_convenio" size="60"/><input type="button" name="button2" id="button2" value="..." onclick="abre_conv()"/></td> <td><input name="tf_agendamento_paciente_matricula" type="text" id="tf_agendamento_paciente_matricula" size="20" /></td> <td><input name="tf_agendamento_paciente_num_guia" type="text" id="tf_agendamento_paciente_num_guia" size="20" /></td> </tr> </table> </body> </html>
form_busca_conv.php:
<!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=utf-8" /> <title>..::Radiologyx>>Agendamento>>Cadastro>>Convênios::..</title> <link href="../css/ris.css" rel="stylesheet" type="text/css" /> <script language="javascript" type="text/javascript" src="../js/convenio.js"></script> <style type="text/css"> td div { height:150px; width:467px; overflow:auto; } </style> </head> <body> <table width="450" border="0" cellspacing="0" cellpadding="0"> <tr> <td valign="top"><img src="../images/interface/lista_conv.gif" width="467" height="20" /></td> </tr> <tr> <td valign="top"><form id="form1" name="form1" method="post" action="form_busca_conv.php"> <table width="450" border="0" id="todoform" cellspacing="0" cellpadding="0"> <tr> <td width="9" valign="top"> </td> <td width="432" valign="top"> </td> <td width="9" valign="top"> </td> </tr> <tr> <td colspan="2" valign="top">Nome:</td> <td width="9" valign="top"> </td> </tr> <tr> <td colspan="3" valign="top"><input name="tf_nome" type="text" id="tf_nome" size="40" maxlength="50" /></td> </tr> <tr> <td valign="top"> </td> <td valign="top"> </td> <td valign="top"> </td> </tr> <tr> <td colspan="3" valign="top"> <table width="435" border="0" align="left" cellpadding="0" cellspacing="2"> <tr> <td width="141" valign="top"><input type=image src="../images/interface/botao_busca.gif" width="130" height="50"></td> <td width="288" valign="top"><img src="../images/interface/botao_cancela.gif" width="130" height="50" border="0" onclick="window.close();"/></td> </tr> </table> </td> </tr> <tr> <td colspan="3" valign="top"> </td> </tr> <tr> <td colspan="3" valign="top"> <? echo "<table width=\"450\" border=0 cellpadding=\"0\" class=\"titulo_negrito\" cellspacing=\"4\"> <tr> <td width=\"350\" align=\"left\">Nome:</td> <td width=\"100\" align=\"left\"></td> </td> </tr> </table>"; ?> <div> <? include "../banco/conecta.php"; if(isset($_POST['tf_nome'])) { $nome = trim(strtoupper($_POST['tf_nome'])); $sql = "SELECT convenio_nome, convenio_id FROM glo_convenios where convenio_nome like '$nome%' and convenio_status='1' order by convenio_nome ASC"; $result = pg_query($conexao,$sql); $i = 1; while ($show = pg_fetch_object($result)) { $nome = $show->convenio_nome; $id = $show->convenio_id; $i++; if(($i%2)!=0){ echo "<table width=\"450\" border=0 cellpadding=\"0\" class=\"texto\" cellspacing=\"4\"> <tr> <td width=\"350\" align=\"left\"><input type=\"radio\" name=\"rg_con\" value=\"$nome|$id\">$nome</td> <td width=\"100\" align=\"left\"></td> </tr> </table>";} else{ echo "<table width=\"450\" bgcolor=\"#D6D6D6\" border=0 cellpadding=\"0\" class=\"texto\" cellspacing=\"4\"> <tr> <td width=\"350\" align=\"left\"><input type=\"radio\" name=\"rg_con\" value=\"$nome|$id\">$nome</td> <td width=\"100\" align=\"left\"></td> </tr> </table>";} } pg_close($conexao); } else { $sql = "SELECT convenio_nome, convenio_id FROM glo_convenios where convenio_status='1' order by convenio_nome ASC"; $result = pg_query($conexao,$sql); $i = 1; while ($show = pg_fetch_object($result)) { $nome = $show->convenio_nome; $id = $show->convenio_id; $i++; if(($i%2)!=0){ echo "<table width=\"450\" border=0 cellpadding=\"0\" class=\"texto\" cellspacing=\"4\"> <tr> <td width=\"350\" align=\"left\"><input type=\"radio\" name=\"rg_con\" value=\"$nome|$id\">$nome</td> <td width=\"100\" align=\"left\"></td> </tr> </table>";} else{ echo "<table width=\"450\" bgcolor=\"#D6D6D6\" border=0 cellpadding=\"0\" class=\"texto\" cellspacing=\"4\"> <tr> <td width=\"350\" align=\"left\"><input type=\"radio\" name=\"rg_con\" value=\"$nome|$id\">$nome</td> <td width=\"100\" align=\"left\"></td> </tr> </table>";} } pg_close($conexao); } ?> </div></td> </tr> <tr> <td valign="top"> </td> <td valign="top"> </td> <td valign="top"> </td> </tr> <tr> <td valign="top"> </td> <td valign="top"><table width="432" border="0" cellspacing="0" cellpadding="0"> <tr> <td align="center"><img src="../images/interface/botao_seleciona.gif" onclick="selecionar()" width="130" height="50" /></td> <td align="center"><img src="../images/interface/botao_inclui.gif" onclick="adicionar()" width="130" height="50" /></td> <td align="center"><img src="../images/interface/botao_edita.gif" onclick="editar()" width="130" height="50" /></td> </tr> </table></td> <td valign="top"> </td> </tr> </table> </form></td> </tr> </table> </body> </html>
convenio.js:
function selecionar(){ var perfil; perfil = document.form1.rg_con.value; for(var i=0;i<document.form1.rg_con.length;i++){ if(document.form1.rg_con[i].checked){ perfil = document.form1.rg_con[i].value; break; } } if(perfil){ var partes = perfil.split('|'); window.opener.document.getElementById("tf_agendamento_paciente_convenio").value = partes[0]; window.opener.document.getElementById("hf_agendamento_paciente_convenio").value = partes[1]; window.close(); }else{ alert("Selecione um convenio."); } } function editar(){ var perfil; perfil = document.form1.rg_con.value; for(var i=0;i<document.form1.rg_con.length;i++){ if(document.form1.rg_con[i].checked){ perfil = document.form1.rg_con[i].value; break; } } if(perfil){ var partes = perfil.split('|'); window.open('form_edita_conv.php?id=' + partes[1], 'Teste44', 'top=110, left=110, width=473, height=335'); window.close(); }else{ alert("Selecione um convenio."); } } function adicionar(){ window.open('form_add_conv.php', 'scisdade1', 'top=110, left=110, width=473, height=335'); window.close(); }
Desculpe se coloquei muita coisa, mas achei que fosse a melhor maneira de vc entender o meu problema, obrigado por enquanto!
#4
Posted 21/01/2011, 11:51

vamos pensar um pouco;;;
/* Na Pagina PAI
precisa chamar a Lib jQuery */
$(document).ready(function(){
$("#hf_agendamento_paciente_convenio").each(function(){ //setar o hidden
$.getJSON("caminho/get_convenio.php",{
var_get_convenio: $('#hf_agendamento_paciente_convenio').val()},
function(json){
//0 = nao exige || 1 = exige
if( json.flStatus == 0){
document.getElementById("Id_campo_matricula").disabled=true;
document.getElementById("id_campo_numero_guia").disabled=true;
}
});
});
});
>>> get_convenio.php
<?php
include "../banco/conecta.php";
if(isset($_GET['var_get_convenio']) !=''){
$sqlString = $_GET['var_get_convenio'];
$query = "SELECT campo_0_ou_1 FROM tabel_convenio WHERE id = $sqlString";
$result = mysql_query($query);
$registro = mysql_fetch_array($result);
$json = '{"flStatus":"'.$registro['campo_0_ou_1'].'"}';
echo json_decode($json);
}
?>
Bom tenta ai.
#5
Posted 21/01/2011, 16:05
Véio............
![]()
vamos pensar um pouco;;;
/* Na Pagina PAI
precisa chamar a Lib jQuery */
$(document).ready(function(){
$("#hf_agendamento_paciente_convenio").each(function(){ //setar o hidden
$.getJSON("caminho/get_convenio.php",{
var_get_convenio: $('#hf_agendamento_paciente_convenio').val()},
function(json){
//0 = nao exige || 1 = exige
if( json.flStatus == 0){
document.getElementById("Id_campo_matricula").disabled=true;
document.getElementById("id_campo_numero_guia").disabled=true;
}
});
});
});
>>> get_convenio.php
<?php
include "../banco/conecta.php";
if(isset($_GET['var_get_convenio']) !=''){
$sqlString = $_GET['var_get_convenio'];
$query = "SELECT campo_0_ou_1 FROM tabel_convenio WHERE id = $sqlString";
$result = mysql_query($query);
$registro = mysql_fetch_array($result);
$json = '{"flStatus":"'.$registro['campo_0_ou_1'].'"}';
echo json_decode($json);
}
?>
Bom tenta ai.
Não deu certo, ve se eu fiz certo por favor:
form_agendamento.php
<!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=utf-8" /> <script type="text/javascript" src="js/jquery-1.4.2.min.js"></script> <script type="text/javascript"> $(document).ready(function(){ $("#hf_agendamento_paciente_convenio").each(function(){ //setar o hidden $.getJSON("functions/jason.php",{ var_get_convenio: $('#hf_agendamento_paciente_convenio').val()}, function(json){ //0 = nao exige || 1 = exige if( json.flStatus == 0){ document.getElementById("tf_agendamento_paciente_matricula").disabled=true; document.getElementById("tf_agendamento_paciente_num_guia").disabled=true; } }); }); }); </script> <script type="text/javascript"> function abre_conv(){ window.open('form_busca_conv.php', 'fornruq1w2w', 'top=110, left=110, width=480, height=395'); } </script> <title>Untitled Document</title> </head> <body> <form id="todoform" name="todoform" method="post" action="banco/agenda_paciente.php" onSubmit="return validaAgenda()"> <table width="776" border="0" cellspacing="4" cellpadding="0"> <tr> <td> </td> <td colspan="2">Convênio:<input type="hidden" name="hf_agendamento_paciente_convenio" id="hf_agendamento_paciente_convenio"/></td> <td>Matrícula:</td> <td>Nro Guia:</td> </tr> <tr> <td> </td> <td colspan="2"><input name="tf_agendamento_paciente_convenio" type="text" id="tf_agendamento_paciente_convenio" size="60"/> <input type="button" name="button2" id="button2" value="..." onclick="abre_conv()"/></td> <td><input name="tf_agendamento_paciente_matricula" type="text" id="tf_agendamento_paciente_matricula" size="20" /></td> <td><input name="tf_agendamento_paciente_num_guia" type="text" id="tf_agendamento_paciente_num_guia" size="20" /></td> </tr> </table> </form> </body> </html>
jason.php
<?php include "../banco/conecta.php"; if(isset($_GET['var_get_convenio']) !=''){ $sqlString = $_GET['var_get_convenio']; $query = "SELECT convenio_matricula FROM glo_convenios WHERE convenio_id = $sqlString"; $result = pg_query($conexao,$sql); $registro = pg_fetch_array($result); $json = '{"flStatus":"'.$registro['convenio_matricula'].'"}'; echo json_decode($json); } ?>
Obrigado!
#6
Posted 21/01/2011, 18:54

vou falar o jeito facil....

o form.html
<!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=utf-8" /> <script type="text/javascript"> function eStatus(Status){ if(Status == 0){ document.getElementById("tf_agendamento_paciente_matricula").style.display ='none'; document.getElementById("tf_agendamento_paciente_num_guia").style.display ='none'; }else{ document.getElementById("tf_agendamento_paciente_matricula").style.display ='block'; document.getElementById("tf_agendamento_paciente_num_guia").style.display ='block'; } } function abre_conv(){ window.open('form_busca_conv.php', 'fornruq1w2w', 'top=110, left=110, width=480, height=395'); } </script> <title>Untitled Document</title> </head> <body> <form id="todoform" name="todoform" method="post" action="banco/agenda_paciente.php" onsubmit="return validaAgenda()"> <table width="776" border="0" cellspacing="4" cellpadding="0"> <tr> <td> </td> <td colspan="2"> Convênio: ID <input type="text" name="hf_agendamento_paciente_convenio" id="hf_agendamento_paciente_convenio" value=""/> </td> <td>Matrícula:</td> <td>Nro Guia:</td> </tr> <tr> <td> </td> <td colspan="2"> <input name="tf_agendamento_paciente_convenio" type="text" id="tf_agendamento_paciente_convenio" size="60"/> <input type="button" name="button2" id="button2" value="..." onclick="abre_conv()"/></td> <td><input name="tf_agendamento_paciente_matricula" type="text" id="tf_agendamento_paciente_matricula" size="20" /></td> <td><input name="tf_agendamento_paciente_num_guia" type="text" id="tf_agendamento_paciente_num_guia" size="20" /></td> </tr> </table> </form> </body> </html>
a busca convenio
<!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> <script> function selecionar(ID, NOME, STATUS){ window.opener.document.getElementById("tf_agendamento_paciente_convenio").value = NOME; window.opener.document.getElementById("hf_agendamento_paciente_convenio").value = ID; window.opener.eStatus(STATUS); window.close(); /* var perfil; perfil = document.form1.rg_con.value; for(var i=0;i<document.form1.rg_con.length;i++){ if(document.form1.rg_con[i].checked){ perfil = document.form1.rg_con[i].value; break; } } if(perfil){ var partes = perfil.split('|'); window.opener.document.getElementById("tf_agendamento_paciente_convenio").value = partes[0]; window.opener.document.getElementById("hf_agendamento_paciente_convenio").value = partes[1]; window.close(); }else{ alert("Selecione um convenio."); } */ } </script> </head> <body> <input type="radio" name="rg_con" value="" onclick="selecionar(1,'Nome 1',1);" /> Nome 1 - status 1 <br /> <input type="radio" name="rg_con" value="" onclick="selecionar(2,'Nome 2',0);" /> Nome 2 - status 0 </body> </html>
mais facil impossivel....

Edição feita por: Leonardo Garcia, 21/01/2011, 18:57.
- barizon likes this
#7
Posted 23/01/2011, 13:56
Bom com como vc se atrabalhou todo...
![]()
vou falar o jeito facil....![]()
o form.html<!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=utf-8" /> <script type="text/javascript"> function eStatus(Status){ if(Status == 0){ document.getElementById("tf_agendamento_paciente_matricula").style.display ='none'; document.getElementById("tf_agendamento_paciente_num_guia").style.display ='none'; }else{ document.getElementById("tf_agendamento_paciente_matricula").style.display ='block'; document.getElementById("tf_agendamento_paciente_num_guia").style.display ='block'; } } function abre_conv(){ window.open('form_busca_conv.php', 'fornruq1w2w', 'top=110, left=110, width=480, height=395'); } </script> <title>Untitled Document</title> </head> <body> <form id="todoform" name="todoform" method="post" action="banco/agenda_paciente.php" onsubmit="return validaAgenda()"> <table width="776" border="0" cellspacing="4" cellpadding="0"> <tr> <td> </td> <td colspan="2"> Convênio: ID <input type="text" name="hf_agendamento_paciente_convenio" id="hf_agendamento_paciente_convenio" value=""/> </td> <td>Matrícula:</td> <td>Nro Guia:</td> </tr> <tr> <td> </td> <td colspan="2"> <input name="tf_agendamento_paciente_convenio" type="text" id="tf_agendamento_paciente_convenio" size="60"/> <input type="button" name="button2" id="button2" value="..." onclick="abre_conv()"/></td> <td><input name="tf_agendamento_paciente_matricula" type="text" id="tf_agendamento_paciente_matricula" size="20" /></td> <td><input name="tf_agendamento_paciente_num_guia" type="text" id="tf_agendamento_paciente_num_guia" size="20" /></td> </tr> </table> </form> </body> </html>
a busca convenio<!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> <script> function selecionar(ID, NOME, STATUS){ window.opener.document.getElementById("tf_agendamento_paciente_convenio").value = NOME; window.opener.document.getElementById("hf_agendamento_paciente_convenio").value = ID; window.opener.eStatus(STATUS); window.close(); /* var perfil; perfil = document.form1.rg_con.value; for(var i=0;i<document.form1.rg_con.length;i++){ if(document.form1.rg_con[i].checked){ perfil = document.form1.rg_con[i].value; break; } } if(perfil){ var partes = perfil.split('|'); window.opener.document.getElementById("tf_agendamento_paciente_convenio").value = partes[0]; window.opener.document.getElementById("hf_agendamento_paciente_convenio").value = partes[1]; window.close(); }else{ alert("Selecione um convenio."); } */ } </script> </head> <body> <input type="radio" name="rg_con" value="" onclick="selecionar(1,'Nome 1',1);" /> Nome 1 - status 1 <br /> <input type="radio" name="rg_con" value="" onclick="selecionar(2,'Nome 2',0);" /> Nome 2 - status 0 </body> </html>
mais facil impossivel....
Perfect!!!....

Tenho mais algumas dúvidas, vc pode me ajudar?

Cara vc já me ajudou muito...obrigado!!!
Edição feita por: barizon, 23/01/2011, 13:59.
1 user(s) are reading this topic
0 membro(s), 1 visitante(s) e 0 membros anônimo(s)