如何在脚本中附加自动搜索类
how can i append auto search class in script
当我单击第一个文本框时,自动完成功能正在工作,但是在脚本中插入另一个文本框后自动完成功能不起作用。所以请建议我如何在脚本中附加自动完成类。
html:
<form id="smart-form-register" class="smart-form client-form" method="post" enctype="multipart/form-data">
<fieldset>
<section>
<label class="input"> <i class="icon-append fa fa-user"></i>
<input type="text" name="product_name" placeholder="product Name">
<b class="tooltip tooltip-bottom-right">Needed to enter product Name</b> </label>
</section>
<section>
<table style="width:100%;">
<tr>
<th style="padding-bottom:10px;">Material Name</th>
<th style="padding-bottom:10px;">Material Quantity</th>
</tr>
<tr>
<td><input name="last[]" class="auto" id="last[0]" size="40"></td>
<td><input name="first[]" id="first[0]" size="40"></td>
</tr>
</table>
</section>
<section>
<span class="glyphicon glyphicon-plus" style="margin-left:580px;" value="Add" onclick="insert()"></span>
</section>
</fieldset>
<input type="submit" name="submit" value="Register" class="btn btn-primary">
</form>
脚本:
<link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.1/themes/base/minified/jquery-ui.min.css" type="text/css" />
<script type="text/javascript" src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<script type="text/javascript" src="http://code.jquery.com/ui/1.10.1/jquery-ui.min.js"></script>
<script type="text/javascript">
$(function() {
//autocomplete
$(".auto").autocomplete({
source: "search1.php",
minLength: 1
});
});
</script>
<script>
var i=0
var j=0
function insert()
{
last=document.getElementById("last["+i+"]")
i++
first=document.getElementById("first["+j+"]")
j++
last.insertAdjacentHTML("AfterEnd", '<br><input class="auto" name="last[]" id="last['+i+']" size="40">')
first.insertAdjacentHTML("AfterEnd", '<br><input name="first[]" id="first['+j+']" size="40"<br>')
}
</script>
只是您在插入新行后调用自动完成脚本函数。将此函数"autocomplete()"添加到"insertAdjacentHTML()"的末尾
<script>
var i=0
var j=0
function insert()
{
last=document.getElementById("last["+i+"]")
i++
first=document.getElementById("first["+j+"]")
j++
last.insertAdjacentHTML("AfterEnd", '<br><input class="auto" name="last[]" id="last['+i+']" size="40">').autocomplete();
first.insertAdjacentHTML("AfterEnd", '<br><input name="first[]" id="first['+j+']" size="40"<br>').autocomplete();
}
</script>
相关文章:
- 如何创建一个脚本,该脚本给定网站列表,它使用其搜索功能来获取信息
- 如何在谷歌应用程序脚本环境中获取谷歌搜索输出
- 谷歌搜索框Java脚本
- jQuery脚本,它搜索现有的查询参数并且不添加“"如果存在
- 谷歌应用程序脚本搜索UI下一个和上一个功能
- 我搜索了一些东西后,自己添加到谷歌的脚本就消失了
- 如何改进我的搜索脚本
- 如何提高搜索脚本的性能
- 有人能解释给我这个基于javascript的内部网站搜索脚本
- 搜索脚本不查找单个单词
- 可以使用XPath搜索脚本吗?块
- jquery搜索脚本
- 从jQuery选项卡搜索脚本中删除链接ID元素
- 简化Javascript和jQuery搜索脚本
- 正在从jQuery搜索脚本中删除keyup
- 使用即时jQuery搜索脚本向页面添加标题
- 当没有HTML返回到jQuery搜索脚本时显示消息
- 即时jQuery搜索脚本的结果页的奇特URL
- 将URL固定到即时JSON搜索脚本的SERP
- 使用此脚本或与之类似的脚本,如何创建搜索脚本来搜索对象