Jump to content


anave

Member Since 15/12/2009
Offline Last Active 21/01/2013, 08:29
-----

#1006277 Pegar Valor De Retorno De Uma Função Jquery

Posted by anave on 17/12/2010, 09:05

Pessoal, estou precisando testar uma condição com o valor retornado de uma função Jquery e usa-la no php, tipo:
Tenho uma consulta q lista todos as informações do banco, nela tenho um input para o usuário digitar algo e fazer a listagem pelas iniciais q ele digitou.
No php puro seria simples, só era pagar via $_POST o que foi digitado. Como o jquery no meu sistema para abrir as páginas secundárias dentro index.php sem dar refresh, isso simplimente não funciona, então coloquei um função para fazer isso, só q ñ estou conseguindo pegar o retorno da função para testar no php, vou colocar os códigos, talvez seja mais fácil de entender assim:
<html xmlns="http://www.w3.org/1999/xhtml">
		<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<title>Untitled Document</title>

		<style type="text/css">
		@import url('css/estilos1.css');
		</style>
        
         <script type="text/javascript">
		$(function(valor) {

			$("#lista_laboratorial").submit(function() {
				var nome_exame = $("#nome_exame").val();
				$("#status").html("<img src='admin/imagens/ajax-loader.gif'/>\nPesquisando...");

				$.post('teste1.php', {nome_exame: nome_exame}, function(resposta) {
					$("#status").slideDown();
					if (resposta != false) {
						$("#status").load("teste1.php",{paramentro:valor})
					} 
					else {
						$("#nome_exame").val("");
					}
				});
			});
		});
	</script>
        
        
	</head>
	<body>
		<form action="javascript:func()" name="lita_laboratorial" id="lista_laboratorial" method="">
	        <div id="status"></div>
            <table width="100%" border="0">
                <td colspan="4">Digite o nome de um exame para consultar :<input name="nome_exame" type="text" id="nome_exame" size="40" maxlength="40" /><input type="submit" name="consulta_exame" id="consulta_exame" value="Ok" />
                    <td colspan="3" align="right"><div><a href="#" url="frm_rlaboratorial.php"><img src="admin/imagens/inserir.gif" alt="" width="80" height="30" border="0" /></a></div></td>
                    <tr>
                        <td width="48%" align="center" class="tarja">Exames</td>
                        <td width="26%" align="center" class="tarja">Categorias</td>
                        <td width="11%" align="center" class="tarja">Data</td>
                        <td align="center" colspan="2" class="tarja">Ação</td>
                    </tr>
                </td>
            </table>
            
            <table width="100%" border="0">
            <?php
// SE FOR DIGITADO ALGO NO INPUT, A FUNÇÃO JQUERY É ESTARTADA E EU QUERO PEGAR SEU RESULTADO AKI 			
				
				if (retorno do jquery verdadeiro) {	
                                      // CONDIÇÃO
				} else
				{
					// CONDIÇÃO
				}

<div id='status'></div>

TESTE1.PHP
<?php
	$nome_exame = $_POST['nome_exame'];
	if (!empty($nome_exame)){
		$nome = 'true';
	}
	else
	{
		$nome = 'false';		
	}
?>

Alguém poderia me ajudar a concluir esse código ?


#995329 [Resolvido] MúLtiplos BotõEs "Submit" Em Um Formul

Posted by anave on 24/02/2010, 14:43

Tô querendo direcionar cada botão submit para um arquivo diferente, então estou fazendo assim:

<input type="submit" value="Enviar" onclick="salvar()">
<input type="submit" value="Retornar" onclick="retornar()">


e entre o <heard></heard> estou fazendo isso:

<script language="JavaScript">


function salvar() {


document.form.action='cad_categoria.php';
document.form.method='POST'
document.form.submit();

}
function retornar() {


document.form.action='inicio.html';
document.form.method='POST'
document.form.submit();

}

</script>


Não está funcionando, simplimente ñ direciona para lugar nenhum.


IPB Skin By Virteq