好吧,伙计们,我有两个功能完美无缺地工作,但不会一起工作,我用Google搜索并发现我可以使用JQuery.NoConflict()函数来避免冲突(显而易见)但我不能管理它工作。
以下是代码:
<script type="text/javascript" src="//code.jquery.com/jquery-3.1.0.js"></script>
<script type='text/javascript'>
window.onload=function(){
$("div").on('click', function() {
var classe = $(this).attr("class");
$("#"+classe).show();
for(var i=0; i<10; ++i){
if(i!=classe){
$("#"+i).hide();
}
}
});
}
<script type="text/javascript" src="autocompletar/lib/jquery.js"></script>
<script type='text/javascript' src='autocompletar/jquery.autocomplete.js'></script>
<script type="text/javascript">
$().ready(function() {
$("#outdsconc").autocomplete("autocompletar/DescConc.php", {
width: 400,
max: 100,
scroll: true,
scrollHeight: 300,
matchContains: true,
selectFirst: false
});
$("#outcdconc").autocomplete("autocompletar/CodConc.php", {
width: 500,
max: 100,
scroll: true,
scrollHeight: 300,
matchContains: true,
selectFirst: false
});
$("#outcdconc").result(function(event, data, formatted) {
if (data)
document.getElementById('outdsconc').value = data[1];
});
$("#outdsconc").result(function(event, data, formatted) {
if (data)
document.getElementById('outcdconc').value = data[1];
});
});
</script>
CodConc.php:
$q = $_GET['q'];
$query_pro = "SELECT CD_AMOSTRACONCORRENTE, DS_AMOSTRACONCORRENTE FROM SPM_AMOSTRACONCORRENTE WHERE CD_AMOSTRACONCORRENTE LIKE '%" . strtoupper($q) . "%' ";
$pro = mssql_query(strtoupper($query_pro)) or die('Erro na query...');
while ($row_pro = mssql_fetch_array($pro)) {
$items[] = $row_pro["DS_AMOSTRACONCORRENTE"] ."|". $row_pro["CD_AMOSTRACONCORRENTE"];
}
if (count($items)>0) {
foreach ($items as $key=>$value) {
$value = explode("|",$value);
echo trim($value[1]) . "|" . trim($value[0]) . "\n";
}
}
DescConc.php:
$q = $_GET['q'];
$query_pro = "SELECT CD_AMOSTRACONCORRENTE, DS_AMOSTRACONCORRENTE FROM SPM_AMOSTRACONCORRENTE WHERE DS_AMOSTRACONCORRENTE LIKE '%" . strtoupper($q) . "%' ";
$pro = mssql_query($query_pro) or die('Erro na query');
while ($row_pro = mssql_fetch_array($pro)) {
$items[] = $row_pro["CD_AMOSTRACONCORRENTE"] ."|". $row_pro["DS_AMOSTRACONCORRENTE"];
}
foreach ($items as $key=>$value) {
$value = explode("|",$value);
echo trim($value[1]) . "|" . trim($value[0]) . "\n";
}
和html:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Administração de Usuários</title>
<style type="text/css">
.invisivel{
display:none;
}
#titulo{
border:1px solid #FC0;
background-color:#FFF6BF;
width:600px;
height:20px;
padding:5px;
text-align:center;
margin:0 auto;
font-size:15px
}
</style>
<-- scripts here -->
</head>
<body>
<table>
<tr>
<td>
<div id="titulo">Provas de Desenvolvimento</div>
</td>
</tr>
<tr>
<td>
<table>
<tr>
<td width="75px" align="right">Pesquisa:</td>
<td height="15px"><input name="outcdpesquisa" size="8" value="<?php echo $row_pesq['CD_PESQUISA'];?>"/></td>
<td><input name="outdspesquisa" size="45" value="<?php echo $row_pesq['DS_PESQUISA'];?>"/></td><td></td></td>
</tr>
</table>
</td>
</tr>
<tr>
<td>
<table>
<tr>
<td width="75px" align="right">Concorrente:</td>
<td height="15px">
<input name="outcdconc" type="text" id="outcdconc" value="<?php echo $_POST['outcdconc']; ?>" size="8"/></td>
<td>
<input name="outdsconc" type="text" id="outdsconc" value="<?php echo $_POST['outdsconc']; ?>" size="45"/></td>
</tr>
</table>
</td>
</tr>
<tr>
<td>
<table>
<tr>
<td width="75px" align="right">Produto:</td>
<td height="15px"><input name="outproduto" size="62"/></td>
</tr>
</table>
</td>
</tr>
<tr>
<td id="esquerda">
<div id="aba" class="1">Escolher Provas</div>
</td>
</tr>
<tr>
<td id="esquerda">
<table class="invisivel" id="1">
<form name="escolherprovas">
<tr>
<td>
<table>
<tr>
<td width="75px" align="right">Usuário: </td>
<td height="15px"><input name="epcdusu" size="8"/></td>
<td><input name="epdescusu" size="45"/></td><td></td></td>
</tr>
</table>
</td>
</tr>
<tr>
<td>
<table>
<tr>
<td width="75px" align="right">Unidade:</td>
<td><select name="epunid">
<option value="gr">gr</option>
<option value="kg">Kg</option>
<option value="ml">ml</option>
<option value="li">li</option>
</select></td>
<td >Lote da Prova:</td>
<td><input name="eploteprova" size="15"/></td>
</tr>
</table>
</td>
</tr>
<tr>
<td>
<table>
<tr>
<td width="75px" align="right">Objetivo:</td>
<td><input name="epobjetivo" type="text" size="63" /></td>
</tr>
</table>
</td>
</tr>
<tr>
<td>
<table>
<tr>
<td width="75px" align="right">Quantidade de<br />Saida Desejada:</td>
<td><input name="epqtd" size="5" /></td>
</tr>
</table>
</td>
</tr>
<tr>
<td>
<table>
<tr>
<td width="75px" align="right">Data:</td>
<td><input name="epdata" type="date" value="<?php echo date('Y-m-d');?>" /></td>
</tr>
</table>
</td>
</tr>
</form>
</table>
</td>
</tr>
<tr>
<td>
<div id="aba" class="2">Processo de Fabricação</div>
</td>
</tr>
<tr>
<td>
<table class="invisivel" id="2">
<form name="processodefabricacao">
<tr>
<td>
<textarea name="pfdesc" rows="8" cols="70"></textarea>
</td>
</tr>
</form>
</table>
</td>
</tr>
<tr>
<td>
<div id="aba" class="3">Formulação</div>
</td>
</tr>
<tr>
<td>
<table class="invisivel" id="3">
<form name="formulacao">
<tr>
<td>
<table>
<tr>
<td width="25%" style="text-align:right;">Matéria Prima:</td>
<td height="15px"><input name="focdmatpri" size="8"/></td>
<td><input name="fodescmatpri"size="45"/></td><td></td>
</tr>
</table>
</td>
</tr>
<tr>
<td>
<table>
<tr>
<td>Quantidade:</td>
<td><input name="foqtd" size="5" /></td>
<td> Lote:</td>
<td><input name="folote" size="8" /></td>
<td> Fornecedor:</td>
<td><input name="fofornec" size="16" /></td>
<td> Custo Unit.:</td>
<td><input name="focusto" size="5" /></td>
</tr>
</table>
</td>
</tr>
</form>
</table>
</td>
</tr>
<tr>
<td>
<div id="aba" class="4">Análises</div>
</td>
</tr>
<tr>
<td>
<table class="invisivel" id="4">
<form name="analises">
<tr>
<td>
<table>
<tr>
<td width="25%" style="text-align:right;">Análise:</td>
<td height="15px"><input name="ancdan" size="8"/></td>
<td><input name="andescan" size="46"/></td><td></td></td>
</tr>
</table>
</td>
</tr>
<tr>
<td>
<table>
<tr>
<td>MAC:</td>
<td><input name="anmac" size="5" /></td>
<td> Unidade:</td>
<td><select name="anunid">
<option value="gr">gr</option>
<option value="kg">Kg</option>
<option value="ml">ml</option>
<option value="li">li</option>
</select></td>
<td> Detalhe:</td>
<td><input name="andetalhe" size="34" /></td>
</tr>
</table>
</td>
</tr>
<tr>
<td>
<table>
<tr>
<td>Res. Conc.:</td>
<td><input name="anresconc" type="text" size="60" /></td>
</tr>
</table>
</td>
</tr>
<tr>
<td>
<table>
<tr>
<td>Resultado:</td>
<td><input name="anres" type="text" size="15" /></td>
<td><button value="">Adicionar</button></td>
</tr>
</table>
</td>
</tr>
</form>
</table>
</td>
</tr>
<tr>
<td>
<div id="aba" class="5">Análises Especificação</div>
</td>
</tr>
<tr>
<td>
<table class="invisivel" id="5" >
<form name="analisesespecificacao">
<tr>
<td>
<table>
<tr>
<td width="50px" align="right">Análise:</td>
<td height="15px"><input name="aecdan" size="8"/></td>
<td><input name="aedescan" size="46"/></td><td></td></td>
</tr>
</table>
</td>
</tr>
<tr>
<td>
<table>
<tr>
<td width="50px" align="right">Nº Ensaio:</td>
<td><input name="aeensaio" size="5" /></td>
<td> UN:</td>
<td><select name="aeunid">
<option value="gr">gr</option>
<option value="kg">Kg</option>
<option value="ml">ml</option>
<option value="li">li</option>
</select></td>
<td> Detalhe:</td>
<td><input name="aedetalhe" size="34" /></td>
</tr>
</table>
</td>
</tr>
<tr>
<td>
<table>
<tr>
<td width="50px" align="right">Status:</td>
<td><select name="aestatus">
<option value="1">1</option>
<option value="2">2</option>
</select></td>
</tr>
</table>
</td>
</tr>
<tr>
<td>
<table>
<tr>
<td width="50px" align="right">Especificação:</td>
<td><input name="aeespec" type="text" size="20" /></td>
</tr>
</table>
</td>
</tr>
</form>
</table>
</td>
</tr>
<tr>
<td>
<div id="aba" class="6">Comentário</div>
</td>
</tr>
<tr>
<td>
<table class="invisivel" id="6">
<form name="comentario">
<tr>
<td>
<textarea name="cocomentario" rows="8" cols="70"></textarea>
</td>
</tr>
</form>
</table>
</td>
</tr>
</table>
</body></html>
如果有人知道通过输入ID自动填写说明的简单方法,那就太棒了。