I’ve created the button:
<input type = "text" name="consulta" size = "12" value = "565656" id = "consulta" />
<input type="button" value = "Pesquisar" onclick="jawa()" />
and the jawa() function is:
function jawa(){
var fieldNameElement = document.getElementById('pesquisa');
//just for test if JS takes values....
resultado = consulta.value;
escolha = cbox.value;
fieldNameElement.innerHTML = "<?echoo();?>";
}
and the echoo() in php…
<?
function echoo(){
if (isset($_POST['consulta'])) {
$con = $_POST['consulta'];
}else{
$con = "not working";
}
$conexao =mysql_pconnect("localhost:3306","xxx","xxx");
mysql_select_db("...",$conexao);
$str_chamado = "Select *
From
`...`.`...`
Where
`NU_TELEFONE`='$con'";
... ?>
it says that “Undefined index: consulta” I can’t get the text from the input, what can it be?
You can’t call a PHP function from Javascript, because PHP it’s interpreted before the page shows and cannot interact with it afterwards.
You can achieve that with Ajax or sending the form and process the values with PHP and the output whatever you want.