[英]How can I get a button to link to a new page, and have a search bar pre filled
So this is a bootstrap drop down menu. 因此,这是一个引导下拉菜单。 I want each button to link to a Product.html page. 我希望每个按钮都链接到Product.html页面。 On that page weare using an Angular JS search bar. 在该页面上,使用Angular JS搜索栏。 I want that search bar to be prefilled with the name of the button, or a word i can type in. I haven't used much of Javascript or jquery. 我希望搜索栏预先填充按钮的名称,或者我可以输入一个词。我没有使用太多的Javascript或jquery。
<ul class="nav navbar-nav navbar-left">
<li class="dropdown">
<a class="dropdown-toggle" data-toggle="dropdown" href="#">Products<span class="caret"></span></a>
<ul class="dropdown-menu">
<li><a href="#">Desktops</a></li>
<li><a href="#">Laptops</a></li>
<li><a href="#">Tablets</a></li>
<li><a href="#">Core Components</a></li>
<li><a href="#">Power Supply</a></li>
<li><a href="#">Hard Drive</a></li>
<li><a href="#">Peripherals</a></li>
</ul>
</li>
</ul>
This is the search, or input on the product.html page. 这是搜索或在product.html页面上的输入。
Search: <input ng-model="query" id = "query" />
I know I need to include, and <script>
"something here" </script>
我知道我需要包括<script>
“这里的东西” </script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
Also do I need to host the website for these calls to work? 我还需要托管网站才能使这些电话正常工作吗? Right now im only testing on a local machine. 目前,我仅在本地计算机上进行测试。
I hope I understood your need correctly. 希望我能正确理解您的需求。 The first way that comes up in my mind would be to append GET
parameter to the urls
(products.html) and get them back in the so called page. 我想到的第一种方法是将GET
参数附加到urls
(products.html)上,然后将它们重新放入所谓的页面中。
It would look like : 它看起来像:
<ul class="nav navbar-nav navbar-left">
<li class="dropdown">
<a class="dropdown-toggle" data-toggle="dropdown" href="#">Products<span class="caret"></span></a>
<ul class="dropdown-menu">
<li><a href="product.html?name=Desktops">Desktops</a></li>
<li><a href="product.html?name=Laptops">Laptops</a></li>
<li><a href="product.html?name=Tablets">Tablets</a></li>
</ul>
</li>
</ul>
and then on the product.html page, you would need to catch this GET parameter back, for that I would suggest you head there to see how you could do it. 然后在product.html页面上,您需要重新获取此GET参数,为此,我建议您去那里看看如何做。
The ' name
' caught, you would then populate the search field with that parameter and then keep on with your logic 捕获到“ name
”,然后您将使用该参数填充搜索字段,然后继续执行您的逻辑
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.