PHP com JAVASCRIPT
Pessoal, Já tentei de tudo e sinceramente não entendo porque não funciona:
Será que alguém poderia me ajudar?
Seguinte misturei PHP com JAVASCRIPT e obtenho a resposta que quero, mas no final o PHP não consegue ler a resposta recebida.
Dá uma olhado no código abaixo:
<?php include "cabecalho_int.php"; ?>
<font face=verdana size=1 color=#FF3300>
<img src="excluir.jpg" width="200" height="50" border="0"><br>
<?php
include "valida_cookies.php";
include "config.php";
?>
<form name=1 method="POST" action="?desejo=excluiredf"><table Border="0" cellpadding="0" cellspacing="0" align="center" width="540">
<tr>
<td width="120">
<font face="Verdana" size="1" color=#008000>Comercio:</font> </td>
<td width="270">
<SELECT name="edificacaoexc" class="formfield" onchange="indxedif.value=options[selectedIndex].value" onclick="textcnpj.value=options[selectedIndex].title">
<?php
include "config.php";
$sql = ("SELECT * FROM $tb1 order by 'nomecomercio','cnpj'");
$req = mysql_query ($sql) or die (' Erreur SQL! <br>'.$sql.' <br>'. mysql_error ());
while($data = mysql_fetch_array($req))
{
$indexedf=$data['id'];
$edificacao=$data['nomecomercio'];
$cnpj=$data['cnpj'];
if (empty($indexfirst)){
$indexfirst=$data['id'];
}
if (empty($cnpjfirst)){
$cnpjfirst=$data['cnpj'];
}
?>
<option value="<?php echo $indexedf;?>" title="<?php echo $cnpj;?>"><?php echo "<font face=\"verdana, tahoma, futura lt bt, arial, microsoft sans serif\" size=\"1\" color=\"#339900\">$edificacao</font>";
?></option>
<?php } ?>
</SELECT><br>
<input border="0" type="text" name="textcnpj" value="<?php echo $cnpjfirst;?>">
<input border="0" type="hidden" name="indxedif" value="<?php echo $indexfirst;?>">
</td>
<td width="70">
<input type="submit" value="Excluir" name="submeter" size="15" style="font-size: 8 pt; font-family: Verdana; font-weight: bold">
</td>
</tr>
</table></form>
</center><td><tr></table>
<?php
include "config.php";
$desejo = $_GET['desejo'];
$cadedific = $_POST['edificacaoexc'];
$sqledf = ("SELECT * FROM $tb1 where id = '$cadedific'");
$reqedf = mysql_query ($sqledf) or die (' Erreur SQL! <br>'.$sqledf.' <br>'. mysql_error ());
while($dataedf = mysql_fetch_array($reqedf))
{
$namedfibox=$dataedf['nome_imovel'];
}
if ($desejo==excluiredf){
if (empty($cadedific)){
echo "<P align=right>Escolha um item na caixa de listagem.<meta http-equiv='refresh' content='3; URL=excadastro.php'>";
}
else {
?>
<script language="JavaScript">
function Certezaedif(){
var nomeedific="<?php echo"$namedfibox"; ?>";
varexcedf = 'ZZZ';
if (confirm ("Deseja realmente Excluir o registro: " + nomeedific + "?")){
varexcedf = 'EOK' } else { varexcedf = 'ENP' }
}
Certezaedif()
</script>
<?php
$excedfsn = '<script>document.write(varexcedf);</script>';;//AQUI ELE RECEBE NORMALMENTEO VALOR DO JAVASCRIPT (varexcedf)
if ($excedfsn == 'EOK'){;//AQUI ELE NÃO ESTA CONSEGUINDO VERIFICAR ESTE VALOR!!!
$sql=mysql_query("DELETE FROM $tb1 where $tb1.id=$cadedific LIMIT 1");
if (!$sql){
echo "<P align=right>Não foi possível excluir o item cadastrado.<meta http-equiv='refresh' content='3; URL=excadastro.php'>";
}
else {
echo "<P align=right>Cadastro excluído com sucesso. $excedfsn<meta http-equiv='refresh' content='3; URL=excadastro.php'>";
}
}
else { echo "<P align=right>Cadastro não excluído. $excedfsn<meta http-equiv='refresh' content='3; URL=excadastro.php'>";
}
}
}
?>
AGRADECERIA MUITO UMA AJUDA DE VOCÊS.
Abraços e Bom Carnaval.
Discussão (5)
Carregando comentários...