Olá
Eu gostaria de, a partir de um arquivo PHP, pegar o valor de um combobox que está em outro arquivo. O arquivo com o combobox é este:
<?
include("verifica.php");
include("configuracao.php");
$db = mysql_connect ($host, $login_db, $senha_db);
$basedados = mysql_select_db($database);
$usuario = mysql_query("SELECT * FROM autentica WHERE login='$login'") or print (mysql_error());
while($linha = mysql_fetch_array($usuario)){
$nomebanco = $linha["nome"];
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Tabela</title>
<br>
<center>
<!-- FILTRO -->
<!-- <form method="post" name="PesquisaForm"> -->
<!-- Comentei a tag form por ele nao ser necessaria, e por estar mal escrita
isso é, ela é aberta aki, mas em nenhuma momento foi fechada. -->
<pre style="font-family: Book Antiqua;">Razão Social:</pre>
<td><input id="pesquisa" type="text" name="pesquisa" size="100"></td>
<input type="button" value="Submit" onClick='load_grid_filter()'/>
<!-- Mudei a tag acima do tipo 'submit'p/ button, adicionei o evento onclick
na nova funcao que criei no site.js... -->
<br><br><br>
</center>
<!-- FILTRO -->
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script src="js/prototype.lite.js"></script>
<script src="js/moo.ajax.js"></script>
<script src="js/site.js"></script>
<noscript>
Habilite o Javascript para visualizar esta página corretamente...
</noscript>
<style>
.borda{border: 1px solid;}
div{font-family: Verdana; font-size: 12px;}
td{font-family: Verdana; font-size: 12px;}
input{font-family: Verdana; font-size: 12px;}
</style>
<center>
</head>
<body onLoad=load_grid()>
<div id="msg" style="visibility: hidden;"> <font face="Verdana" size="2">Processando...</font></div>
<div id="resultado"></div>
<br>
</center>
<div>
<form name="formulario">
<table width="300" border="0">
<tr>
<td>Bloqueado:</td>
<td><select size="1" name="D1" id="D1">
<option selected value="F">F</option>
<option value="V">V</option>
</select>
</tr>
<tr>
<td>Razão Social:</td>
<td><input id="nome" type="text" name="nome" size="25"></td>
</tr>
<tr>
<td>Bloqueado:</td>
<td><input id="email" type="text" name="email" size="25"></td>
</tr>
<tr>
<td>Nome Fantasia:</td>
<td><input id="fone" type="text" name="fone" size="25"></td>
</tr>
<tr>
<td><input type="button" id="botao" value="Incluir" onClick=valida_form()></td>
<td><input type="hidden" id="acao" value=""></td>
</tr>
</table>
</form>
</div>
</body>
</html>
O arquivo com a função de inserção é esse:
// JavaScript Document
function load_grid(){
new ajax ('seleciona.php', {onLoading: carregando, onComplete: imprime});
limpa_form();
}
function load_grid_filter() {
// Este código obtém o filtro digitado no 'R.Social' e passa como argumento p/ o php
var filter_value = document.getElementById('pesquisa').value;
// Nesse momento, eu estou usando o código crente que o código de origem('load_grid') esteja funcionando.
// Como eu falei, não tenho/conheço esses componentes, então, não pude testar como se deve.
new ajax ('seleciona.php?pesquisa=' + filter_value, {onLoading: carregando, onComplete: imprime});
limpa_form();
}
function enviar(){
if($("acao").value=="inserir")
new ajax ('insere.php?nome=' + document.getElementById('nome').value + '&email=' + document.getElementById('email').value + '&fone=' + document.getElementById('fone').value, {onLoading: carregando, onComplete: load_grid});
else if($("acao").value=="alterar")
new ajax ('altera.php?nome=' + document.getElementById('nome').value + '&email=' + document.getElementById('D1').value + '&fone=' + document.getElementById('fone').value + "&id=" + array[0], {onLoading: carregando, onComplete: load_grid});
}
function apagar(id){
var resposta = confirm("Deseja remover esse registro?");
if (resposta)
new ajax ('apaga.php?id=' + id, {onLoading: carregando, onComplete: load_grid});
}
function editar(texto){
if(navigator.appName=='Microsoft Internet Explorer'){
array=texto.split("<TD>");
texto=array.join("");
array=texto.split("</TD>");
}
else{
array=texto.split("<td>");
texto=array.join("");
array=texto.split("</td>")
}
$("nome").value=array[1];
$("email").value=array[2];
$("fone").value=array[3];
$("D1").value=array[2];
$("acao").value="alterar";
$("botao").value="Alterar";
}
function valida_form(){
if($("nome").value==""){
alert("Preencha o campo Nome")
return false;
}
else if($("email").value==""){
alert("Preencha o campo Email")
return false;
}
else if($("fone").value==""){
alert("Preencha o campo Telefone")
return false;
}
else
enviar();
}
function limpa_form(){
$("acao").value="inserir";
$("botao").value="Incluir";
$("nome").value="";
$("email").value="";
$("fone").value="";
}
function carregando(){
$("msg").style.visibility="visible";
$("msg").innerHTML="Processando...";
}
function imprime(request){
$("msg").style.visibility="hidden";
var xmldoc=request.responseXML;
var cabecalho = xmldoc.getElementsByTagName('cabecalho')[0];
if(cabecalho!=null)
{
var campo = cabecalho.getElementsByTagName('campo');
var tabela="<table class='borda'><tr>"
//cabecalho da tabela
for(i=0;i<campo.length;i++){
tabela+="<td class='borda'><b>"+campo[i].firstChild.data+"</b></td>";
}
tabela+="<td colspan='2' class='borda'><b>Controles</b></td>"
tabela+="</tr>"
//corpo da tabela
var registros = xmldoc.getElementsByTagName('registro');
for(i=0;i<registros.length;i++){
var itens = registros[i].getElementsByTagName('item');
tabela+="<tr id=linha"+i+">"
for(j=0;j<itens.length;j++){
if(itens[j].firstChild==null)
tabela+="<td></td>";
else
tabela+="<td>"+itens[j].firstChild.data+"</td>";
}
tabela+="<td style='cursor: pointer'><img src='imagens/edit.gif' onClick=editar($('linha"+i+"').innerHTML)></td>";
tabela+="<td style='cursor: pointer'><img src='imagens/delete.gif' onClick=apagar("+itens[0].firstChild.data+")></td>";
tabela+="</tr>";
}
tabela+="</table>"
$("resultado").innerHTML=tabela;
tabela=null;
}
else
$("resultado").innerHTML="Nenhum registro encontrado...";
}
e tento passar o valor aqui:
<?php
require_once("include/conexao.inc.php");
require_once("include/Clbanco.php");
$id=$_GET["id"];
$nome=$_GET["nome"];
$email=$_GET["email"];
$fone=$_GET["fone"];
$teste=$_GET["D1"];
$cadastro = new banco($conn,$db);
$cadastro->altera("empresa","RAZAOSOCIAL='$nome',BLOQUEADO='$teste',NOMEFANTASIA='$fone'","$id");
mysql_close($conn);
exit();
?>
Alguém aí sabe qual é o problema? Já tentei isso tudo e nada funciona. Dessa forma o valor vai em branco.
Obrigado.