简体   繁体   English

如何获得一个链接到新页面的按钮,并预先填充搜索栏

[英]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.

相关问题 如何获得返回按钮链接以返回到原始搜索页面? - How can I get a back button link to return to ORIGINAL search page? 如何在 React 和新页面中链接 2 个组件仍然有导航栏 - How to link 2 components in React and in a new page still have a navigation bar 我如何检查TEXTAREA是否在另一个页面上用按钮填充? - how can I check if a TEXTAREA is filled on another page with a button? 如何在JavaScript代码中包含刷新页面链接/按钮? - How can I have refresh page link/button inside my JavaScript code? 如何使用Jade处理可能预先填写的表格? - How can I handle a potentially pre-filled form with Jade? 单击或输入后,如何获取搜索栏中的信息。 然后将其粘贴到另一页上的另一个输入中? - How can I get the Information in search bar on click or Enter. Then paste it to another input on another page? 如何获取此按钮中的链接? - How can I get the link in this button? 如何从用户那里获取输入(他们将输入链接)并将其存储在按钮内并重定向? - How can I get input(they will input a link) from user and store it inside of a button and have it redirect? 使用Redux表单,如果未填写任何字段,如何禁用提交按钮? - Using Redux Form, how can I disable the submit button if no fields have been filled out? 搜索栏正在搜索图像源链接,如何使其搜索名称? - Search bar is searching for image source link, how can I make it search for a name instead?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM