搜索后在文本框中获取数据 [英] fetch data in the textboxes after search

查看:49
本文介绍了搜索后在文本框中获取数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

任何人都可以帮助我使用我的代码,因为我只是网络开发中的新功能...我想对我的程序执行的操作是,如果我将批处理代码搜索到搜索文本框,它将自动过滤并显示在相应的texbox中。 />


在我当前的代码中无法正常工作...我需要你帮助的人...请



例子:我希望我的输出是这样的。



http://s38.photobucket.com/user/eloginko/media/aa_zpsd1e1659b.png.html [ ^ ]







html代码:



can anyone help me with my code because im just new in web developing...i want to do to my program is if i search a batchcode to a search textbox it will automatically filter and shows in their corresponding texboxes.

in my current code its not working...i need your help guys...please

example: i want my output to be like this.

http://s38.photobucket.com/user/eloginko/media/aa_zpsd1e1659b.png.html[^]



html code:

<form method="post">
Search batchcode: <input type="text" name="code" id="query" /><input type="submit" value="Go" name="search" /><br />
<table>
<tr>
<td>
ID: <br />
<input id="result" type="text" name="id1" value="<?php if(empty($id[0])){$id[0] = array(NULL);}else{echo $id[0];} ?>" readonly /> <br />
<input id="result" type="text" name="id2" value="<?php if(empty($id[1])){$id[1] = array(NULL);}else{echo $id[1];} ?>" readonly /> <br />
</td>
<td>
Name: <br />
<input id="result" type="text" name="name1" value="<?php if(empty($name[0])){$name[0] = array(NULL);}else{echo $name[0];} ?>" readonly /> <br />
<input id="result" type="text" name="name2" value="<?php if(empty($name[1])){$name[1] = array(NULL);}else{echo $name[1];} ?>" readonly /> <br />
</td>
<td>
Score 1: <br />
<input id="result" type="text" name="optA1" value="<?php if(empty($score1[0])){$score1[0] = array(NULL);}else{echo $score1[0];} ?>" onChange="optTotal1()" /> <br />
<input id="result" type="text" name="optA2" value="<?php if(empty($score1[1])){$score1[1] = array(NULL);}else{echo $score1[1];} ?>" onChange="optTotal2()" /> <br />
</td>
<td>
Score 2: <br />
<input id="result" type="text" name="optB1" value="<?php if(empty($score2[0])){$score2[0] = array(NULL);}else{echo $score2[0];} ?>" onChange="optTotal1()" /> <br />
<input id="result" type="text" name="optB2" value="<?php if(empty($score2[1])){$score2[1] = array(NULL);}else{echo $score2[1];} ?>" onChange="optTotal2()" /> <br />
</td>
<td>
Other Qualification: <br />
<input id="result" type="text" name="other_qual1" value="<?php if(empty($other_qual[0])){$other_qual[0] = array(NULL);}else{echo $other_qual[0];} ?>" readonly /> <br />
<input id="result" type="text" name="other_qual2" value="<?php if(empty($other_qual[1])){$other_qual[1] = array(NULL);}else{echo $other_qual[1];} ?>" readonly /> <br />
</td>
<td>
Interview: <br />
<input id="result" type="text" name="interview1" value="<?php if(empty($interview[0])){$interview[0] = array(NULL);}else{echo $interview[0];} ?>" readonly /> <br />
<input id="result" type="text" name="interview2" value="<?php if(empty($interview[1])){$interview[1] = array(NULL);}else{echo $interview[1];} ?>" readonly /> <br />
</td>
<td>
Total: <br />
<input id="result" type="text" name="total1" value="<?php if(empty($total[0])){$total[0] = array(NULL);}else{echo $total[0];} ?>" readonly onKeyUp="optTotal1()" /> <br />
<input id="result" type="text" name="total2" value="<?php if(empty($total[1])){$total[1] = array(NULL);}else{echo $total[1];} ?>" readonly onKeyUp="optTotal2()" /> <br />
</td>
</tr>
</table>
<input type="submit" value="update" name="update" />
</form>



< br $> b $ b



搜索功能脚本:







script for search function:

<script type="text/javascript">
$(document).ready(function(){

    $("#query").autocomplete({
        source : 'search.php',
        select : function(event,ui){
            $("#result").html(ui.item.value);
        }
    });

});
</script>







search.php页码:








search.php page code:


<?php

$q = $_GET['term'];

mysql_connect("localhost","root","");
mysql_select_db("test");
$batchcode = $_POST['code'];
$query = mysql_query("SELECT DISTINCT batchcode FROM score WHERE batchcode LIKE '$q%'");

$data = array();
while($row = mysql_fetch_array($query)){
$data[]=array('value'=>$row['batchcode']);
        $id[] = $rows['id'];
        $name[] = $rows['name'];
        $score1[] = $rows['score1'];
        $score2[] = $rows['score2'];
        $other_qual[] = $rows['score3'];
        $interview[] = $rows['score4'];
        $total[] = $rows['total'];
}
echo json_encode($data);


?>

推荐答案

id [0])){


id [0] = array(NULL);} else {echo
id[0] = array(NULL);}else{echo


id [0] ;}?> readonly / > < br / >
< 输入 id = 结果 type = text name = id2 value < span class =code-keyword> = <?php if(empty(
id[0];} ?>" readonly /> <br /> <input id="result" type="text" name="id2" value="<?php if(empty(


这篇关于搜索后在文本框中获取数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆