0
I have a problem in my code, I needed to do a search field only I came across a problem input fields ignores the function javascript and jquery and in the case of inputs Submit nor update my code page is as follows:
//javascript part:
<script src="https://code.jquery.com/jquery-1.10.2.js"></script>
</script>
<script>
jQuery.noConflict();
(function($) {
$('#bs-mrb').on('keyup',function(e){
if(e.which == 13) {
// if($('#bs-prod').val() != "") {
var dato = $('#bs-mrb').val();
var x = $('#str').val();
var url = x+'_functions.php?action=buscaMrb';
// alert("dato: "+dato+" x: "+x+" url: "+url);
$.ajax({
type:'POST',
url:url,
data:'dato='+dato,
success: function(datos){
$('#agrega-registros').html(datos);
r1 = tooltip();
}
});
return false;
}
// }
});
})(jQuery);
</script>
//HTML part:
<body onLoad="tooltip();">
<?php
$funcao = $_REQUEST["op"];
if (function_exists($funcao)) {
call_user_func($funcao);
}
function saida() {
titulo("FA - saída","course.png") ?>
<section>
<table border="0" align="center">
<tr>
<td>
<input type="hidden" name="str" id="str" value="aqm"/>
</td>
<form name="frm_pesq" method="post" action="">
<td width="300">
<input type="text" placeholder="ID / PartNumber / SN Item" name="pesq" size="25" id="bs-mrb">
<input type="hidden" name="str" id="str" value="fa"/>
</td>
</form>
</tr>
</table>
</section>
<div class="registros" id="agrega-registros">
<table class="table table-striped table-condensed table-hover nowrap">
<thead class="head">
<th nowrap width="10px">Status</th>
<th nowrap width="50px">ID</th>
<th nowrap width="160px">DataEntrada</th>
<th nowrap width="120px">PartNumber</th>
<th nowrap width="140px">SNItem</th>
<th nowrap width="140px">Description</th>
<th nowrap width="150px">Defect</th>
<th nowrap width="150px">TransferOrder</th>
<th nowrap width="10px">teste</th>
</thead>
<?php
aqui vai a query select * from tabela;
e trás as informações do banco.
após isso fecho a função saída();
} ?>
</table>
</div>
In the input field id="bs-mrb"
does not call any function I’ve tried javascript and jquery does not work only recognized a alert();
by placing inside the input for example:
<input type="text" value="pesquisar" id="bs-mrb" onkeypress="alert('teste');">
So it worked more if I put an Alert in a function does not work someone can help me in that.
Detail my query is working the problem is only in the call of the javascript function in the input and also I have tried to make an onsubmit inside the form and it did not work and also this page I am calling inside of one of other page index.
with the code below:
//javascript calling the page above.
<script>
function display_c(){
setInterval('getInfo()',30000);
}
function getInfo(){
var xmlhttp;
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp = new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
document.getElementById("conteudo").innerHTML = xmlhttp.responseText;
}
};
xmlhttp.open("GET", "MRB_Dados.php?op=<?php echo $op;?>", true);
xmlhttp.send('conteudo');
}
</script>
//and the html part that receives the page above within the content div.
<body onload="display_c(); getInfo('<?php echo $op ; ?>');">
<div id="header">
<div id="masthead_upper" class="masthead full fullwidth">
<div class="container_20">
<div class="grid_6" id="logo"> <a href="http://<?php echo $_SERVER['SERVER_NAME'] ?>/coffe/mrb.php?op=<?php echo $op;?>">Lenovo</a> </div>
<div style="position:absolute;color:white;font-family:Arial;font-size:32px;top:15px; right:20px; text-align: right;">Controle</div>
<div style="position:absolute;color:white;font-family:Arial;font-size:10px;top:48px; right:20px; text-align: right;">Developed by Engineering System</div>
<div style="position:absolute;top:65px; left:10px; text-align: left;">
<nav class="grid_20 cf" id="menus">
<ul class="fullwidth" id="navigation"><br>
<li class="first" id="laptops"><font color="#FFCC00" face="verdana" size="2"><b><?php echo strtoupper($_SESSION['usuario'])." - ".strtoupper($_SESSION['nome']);?></b></font>
<?php if(!empty($_SESSION['usuario'])) { ?>
<font color="#FFCC00" face="verdana" size="2"><?php echo " - ".strtoupper($_SESSION['depto']);?>| <a style="color: #fff;" href="logout.php">[logout]</a> | <span id="countDown" style="color:white"></span></font>
<?php } ?>
</li>
</ul>
</nav>
</div>
</div>
</div>
</div>
<div id="container">
<!-- begin: Main Grid -->
<table width="99%" border="0" cellspacing="0" cellpadding="0" align="center">
<tr>
<td width="100%" align="left" valign="top" bgcolor="#FFFFFF" class="landingcontent"><br />
<table width="100%" height="100%" border="1" cellpadding="4" cellspacing="0">
<tr>
<td class="columnR" width="87%" valign="top" align="left">
<!-- inicio td -->
<div id="conteudo"></div>
<!-- fim td -->
</td>
</tr>
</table>
</td>
</tr>
</table>
</div>
<!-- end: Main Grid -->
<!-- begin: Footer -->
<?php // include "footer.php"; ?>
</body>
</html>
Emir I did some tests here the Submit does not work because the page that is running inside a <div> of another page tested out works
– Danilo Eugenio
It’s little confusing your question. You want to give a button Submit ccom or use ajax with jquery?
– Emir Marques