Abraços Walker
Selecionar Combobox E Imprimir Em Textarea...
			
				
					
						
					
					#1
					
					
				
				
				
					
				
			
				
			
			
			Posted 02/04/2008, 23:13
Abraços Walker
			
				
					
						
					
					#2
					
					
				
				
				
					
				
			
				
			
			
			Posted 03/04/2008, 08:43
			
				
					
						
					
					#3
					
					
				
				
				
					
				
			
				
			
			
			Posted 03/04/2008, 11:20
Edição feita por: willwalker, 03/04/2008, 11:35.
			
				
					
						
					
					#4
					
					
				
				
				
					
				
			
				
			
			
			Posted 03/04/2008, 13:11
//php para gerar as options
?>
<select onchange="Ajuda(this.value)">
<option value="1">op 1</option>
<option value="2">op 2</option>
<option value="3">op 3</option>
</select>
<div id="resultado"></div>
<script type="text/javascript">
function ajaxInit() {
var xmlhttp;
//verifica se o browser tem suporte a ajax
try {
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
catch(e) {
try {
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
}
catch(ex) {
try {
xmlhttp = new XMLHttpRequest();
}
catch(exc) {
alert("Esse browser não tem recursos para uso do Ajax. Por favor atualize seu Navegador!");
xmlhttp = null;
}
}
}
return xmlhttp;
}
function LoadAjax(obj) {
ajax = ajaxInit();
if (ajax) {
ajax.onreadystatechange = function () {
if(ajax.readyState == 1) {
document.getElementById(obj).innerHTML = 'carregando...';
}
if(ajax.readyState == 4 ) {
if(ajax.responseText) {
processTEXT(ajax.responseText,obj);
}
else {
//caso não seja um arquivo XML emite a mensagem abaixo
document.getElementById(obj).innerHTML = "Erro ao carregar!";
}
}
}
ajax.open('GET', "script_php_que_faz_a_consulta_no_bd.php", true);
ajax.send(null);
}
}
function processTEXT(retorno) {
document.getElementById("resultado").innerHTML = retorno;
}
//function q chama o ajax
function Ajuda(obj) {
LoadAjax(obj);
}
</script>[/codebox]
vc só precisa alterar o nome do script q faz a consulta no banco de dados para te trazer as resposta ...
qualquer coisa posta aí
flw
			
				
					
						
					
					#5
					
					
				
				
				
					
				
			
				
			
			
			Posted 04/04/2008, 02:15
Tentei fazer isso, mas na verdade eu só coloquei o que eu sei... =]
Como posso fazer com que o textarea que ainda não coloquei pegue a celula solucao ao selecionar o id do registro na combobox ?
<p><?php
if( $_SESSION['nivel'] == "adm" ){
$sQuery = "SELECT * FROM chamados ORDER BY codigo DESC";
$oPessoa = mysql_query($sQuery);
}else{
$sQuery = "SELECT * FROM chamados WHERE acessor='".$_SESSION['nom_usuario']."' ORDER BY codigo DESC";
$oPessoa = mysql_query($sQuery);
}
?>Tramitação<br>
<select name="tramita" id="tramita">
<option value="na"></option><?php
while( $rs = mysql_fetch_array($oPessoa) )
{
$nome_print = $rs["id"];
echo "<option value='$nome_print'>$nome_print</option>";
}
?>
</select></p>
<div id="resultado"></div>
<script type="text/javascript">
function ajaxInit() {
var xmlhttp;
//verifica se o browser tem suporte a ajax
try {
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
catch(e) {
try {
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
}
catch(ex) {
try {
xmlhttp = new XMLHttpRequest();
}
catch(exc) {
alert("Esse browser não tem recursos para uso do Ajax. Por favor atualize seu Navegador!");
xmlhttp = null;
}
}
}
return xmlhttp;
}
function LoadAjax(obj) {
ajax = ajaxInit();
if (ajax) {
ajax.onreadystatechange = function () {
if(ajax.readyState == 1) {
document.getElementById(obj).innerHTML = 'Carregando...';
}
if(ajax.readyState == 4 ) {
if(ajax.responseText) {
processTEXT(ajax.responseText,obj);
}
else {
//caso não seja um arquivo XML emite a mensagem abaixo
document.getElementById(obj).innerHTML = "Erro ao carregar!";
}
}
}
ajax.open('GET', "config.php", true);
ajax.send(null);
}
}
function processTEXT(retorno) {
document.getElementById("resultado").innerHTML = retorno;
}
//function q chama o ajax
function Ajuda(obj) {
LoadAjax(obj);
}
</script>
			
				
					
						
					
					#6
					
					
				
				
				
					
				
			
				
			
			
			Posted 04/04/2008, 08:50
<select onchange = "Ajuda("id_da_textarea")">
... options...
</select>
e troca isto:
function processTEXT(retorno) {
document.getElementById("resultado").innerHTML = retorno;
}
por isto:
function processTEXT(retorno) {
document.getElementById("id_da_textarea").value = retorno;
}
qdo o ajax acabar de carregar ele chama esta funcao e passa pra ela o resultado obtido, uma vez passado a funcao define o valor da textarea
			
				
					
						
					
					#7
					
					
				
				
				
					
				
			
				
			
			
			Posted 04/04/2008, 10:44
ajax.open('GET', "config.php", true);
Um amigo me explicou que seria assim:
ajax.open('GET', "config.php?id=<?=.$_GET["id"]; ?>", true);
Mas o que conteria nesse arquivo php ? Tem que usar o xml tambem ? Ou só o arquivo php ? Porque eu li sobre ajax e ele usa arquivos xml que importam dados do banco criando um xml com o valores...
Edição feita por: willwalker, 04/04/2008, 10:59.
			
				
					
						
					
					#8
					
					
				
				
				
					
				
			
				
			
			
			Posted 04/04/2008, 10:58
segue um codigo para melhor entendimento
<p><?php
if( $_SESSION['nivel'] == "adm" ){
$sQuery = "SELECT * FROM chamados ORDER BY codigo DESC";
$oPessoa = mysql_query($sQuery);
}else{
$sQuery = "SELECT * FROM chamados WHERE acessor='".$_SESSION['nom_usuario']."' ORDER BY codigo DESC";
$oPessoa = mysql_query($sQuery);
}
?>Tramitação<br>
<select name="tramita" id="tramita" onchange="Ajuda('resultado',this.value)">
<option value="na"></option><?php
while( $rs = mysql_fetch_array($oPessoa) )
{
$nome_print = $rs["id"];
echo "<option value='$nome_print'>$nome_print</option>";
}
?>
</select></p>
<div id="resultado"></div>
<script type="text/javascript">
function ajaxInit() {
var xmlhttp;
//verifica se o browser tem suporte a ajax
try {
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
catch(e) {
try {
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
}
catch(ex) {
try {
xmlhttp = new XMLHttpRequest();
}
catch(exc) {
alert("Esse browser não tem recursos para uso do Ajax. Por favor atualize seu Navegador!");
xmlhttp = null;
}
}
}
return xmlhttp;
}
function LoadAjax(obj, parametro) {
ajax = ajaxInit();
if (ajax) {
ajax.onreadystatechange = function () {
if(ajax.readyState == 1) {
document.getElementById(obj).innerHTML = 'Carregando...';
}
if(ajax.readyState == 4 ) {
if(ajax.responseText) {
processTEXT(ajax.responseText,obj);
}
else {
//caso não seja um arquivo XML emite a mensagem abaixo
document.getElementById(obj).innerHTML = "Erro ao carregar!";
}
}
}
ajax.open('GET', "config.php?q="+parametro, true);
ajax.send(null);
}
}
function processTEXT(retorno) {
document.getElementById("resultado").innerHTML = retorno;
}
//function q chama o ajax
function Ajuda(obj, parametro) {
LoadAjax(obj, parametro);
}
</script>teu arquivo config.php ficaria assim:
$var = $_GET['q']; <? codigo php q faz a consulta echo $resposta; ?>
qualquer coisa posta aí
			
				
					
						
					
					#9
					
					
				
				
				
					
				
			
				
			
			
			Posted 04/04/2008, 12:57
[codebox]<p><?php
if( $_SESSION['nivel'] == "adm" ){
$sQuery = "SELECT * FROM chamados ORDER BY codigo DESC";
$oPessoa = mysql_query($sQuery);
}else{
$sQuery = "SELECT * FROM chamados
WHERE acessor='".$_SESSION['nom_usuario']."' ORDER BY codigo DESC";
$oPessoa = mysql_query($sQuery);
}
?>Tramitação<br>
<select name="tramita" id="tramita" onchange="Ajuda(solucao)">
<option value="na"></option><?php
while( $rs = mysql_fetch_array($oPessoa) )
{
$nome_print = $rs["id"];
echo "<option value='$nome_print'>$nome_print</option>";
}
?>
</select></p>
<div id="solucao" align="center">
<textarea id="solucao" name="solucao" cols="35" rows="4"></textarea>
</div>
<script type="text/javascript">
function ajaxInit() {
var xmlhttp;
//verifica se o browser tem suporte a ajax
try {
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
catch(e) {
try {
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
}
catch(ex) {
try {
xmlhttp = new XMLHttpRequest();
}
catch(exc) {
alert("Esse browser não tem recursos para uso do Ajax. Por favor atualize seu Navegador!");
xmlhttp = null;
}
}
}
return xmlhttp;
}
function LoadAjax(obj) {
ajax = ajaxInit();
if (ajax) {
ajax.onreadystatechange = function () {
if(ajax.readyState == 1) {
document.getElementById("solucao").innerHTML = 'Carregando...';
}
if(ajax.readyState == 4 ) {
if(ajax.responseText) {
processTEXT(ajax.responseText,obj);
}
else {
//caso não seja um arquivo XML emite a mensagem abaixo
document.getElementById("solucao").innerHTML = "Erro ao carregar!";
}
}
}
ajax.open('GET', "teste.php?id="+obj, true);
ajax.send(null);
}
}
function processTEXT(retorno) {
document.getElementById("solucao").innerHTML = retorno;
}
//function q chama o ajax
function Ajuda(obj) {
LoadAjax(obj);
}
</script>[/codebox]
[codebox]<?php
require("config.php");
require("layout.php");
$id = $_GET["id"];
$sql = mysql_query("SELECT * FROM chamados WHERE id='$id'");
while($row = mysql_fetch_array($sql))
{
echo $row ["solucao"];
}
?>[/codebox]
Edição feita por: willwalker, 04/04/2008, 12:58.
			
				
					
						
					
					#10
					
					
				
				
				
					
				
			
				
			
			
			Posted 04/04/2008, 13:31
$nome_print = $rs["id"];
echo "<option value='$nome_print'>$nome_print</option>";
}
			
				
					
						
					
					#11
					
					
				
				
				
					
				
			
				
			
			
			Posted 04/04/2008, 14:24
Edição feita por: willwalker, 04/04/2008, 14:25.
			
				
					
						
					
					#12
					
					
				
				
				
					
				
			
				
			
			
			Posted 04/04/2008, 14:42
qualquer coisa posta aí ...
flw
			
				
					
						
					
					#13
					
					
				
				
				
					
				
			
				
			
			
			Posted 10/04/2008, 20:09
					
					
			
				
					
						
					
					#14
					
					
				
				
				
					
				
			
				
			
			
			Posted 10/04/2008, 20:50
qualquer coisa posta aí
flw
			
				
					
						
					
					#15
					
					
				
				
				
					
				
			
				
			
			
			Posted 25/05/2008, 07:16
1 user(s) are reading this topic
0 membro(s), 1 visitante(s) e 0 membros anônimo(s)










