We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 38004
    • 96 Posts
    Ah ok.

    I haven't made a form yet.

    I'm looking for just a few simple drop downs.

    Sort by: Category | Manufacturer | Size

    How would I then tell the form to pass the information to getResources?
      • 15083
      • 697 Posts
      What are ur TV's called to filter by firstly?

      Create a form:

      <form>
      TV Filter one:
      <select name="name_of_tv_filter">
        <option value="volvo">Volvo</option>
        <option value="saab">Saab</option>
        <option value="mercedes">Mercedes</option>
        <option value="audi">Audi</option>
      </select>
      </form>


      try calling the snippet I gave you and pass in name_of_tv_filter
      Please don't copy and paste from this form btw, I am using broken hacky syntax for the snippets!
        • 38004
        • 96 Posts
        My tvs are called:

        product_brand (single select list)
        product_category (single select list)
        product_size (multi select list)
        product_price (note this is a numerical text entry)

        Here is the start of a basic form with two of those TVs: I don't know anything about forms or how to make it automatically pick up the TVs

         <form class="form" action="(DON't KNOW WHAT TO PUT HERE" method="get" >
        <div>
        <label for="qwe">Search for products</label>
        <div style="display: none; " id="cat_tree_0"/>
        <input type="hidden" name="qwe" id="qwe" value="0"/>
        <div id="sel_place"/>
        </div>
        <div>
        <label for="name">Keyword</label>
        <input id="name" type="text" name="keyword"/>
        </div>
        <div>
        <label for="product_category">Product category</label>
        <select name="product_category" id="product_category">
        <option value="">-- Please select --</option>
        <option value="Headlights">Headlights</option>
        <option value="HIDs">HIDs</option>
        <option value="Sidielights">Sidielights</option>
        <option value="Brake lights">Brake lights</option>
        <option value="Indicators">Indicators</option>
        <option value="Misc">Misc</option>
        </select>
        </div>
        <div>
        <label for="product_brand">Product Manufacturer</label>
        <select name="product_brand" id="product_brand">
        <option value="">-- Please select --</option>
        <option value="Philips">Philips</option>
        <option value="Osram">Osram</option>
        <option value="Ring">Ring</option>
        <option value="Bosch">Bosch</option>
        <option value="Other">Other</option>
        </select>
        </div>
        <div class="form-buttons">
        <input type="submit" value="submit"/>
        </div>
        </form>   
          • 15083
          • 697 Posts
          OK the DON't KNOW WHAT TO PUT HERE =

          [[~[[*id]]]]


          That set of MODx tags will force the form to POST back to itself.
          So you will be posting back:
          product_brand
          product_category

          Try calling the snippet I wrote with the above, to see it it effects the results from getResources
          It Should!
            • 15083
            • 697 Posts
            Also it looks to me like you are making some sort of shopping cart/directory.
            Have you looked at vision cart?
              • 38004
              • 96 Posts
              I'm using Foxycart for store, but it's only concerned with adding to a cart and handling the checkout process. Everything else is handled by modx.

              <form class="form" action="[[!my_user_search_form? &post_var_name='name' ]]" method="post">
              <div><label for="qwe">Search for products</label>
              <div id="cat_tree_0" style="display: none;"> </div>
              <input id="qwe" type="hidden" name="qwe" value="0" />
              <div id="sel_place"> </div>
              </div>
              <div><label for="name">Keyword</label> <input id="name" type="text" name="keyword" /></div>
              <div><label for="product_category">Product category</label> <select id="product_category" name="product_category"> <option value="">-- Please select --</option> <option value="Headlights">Headlights</option> <option value="HIDs">HIDs</option> <option value="Sidielights">Sidielights</option> <option value="Brake lights">Brake lights</option> <option value="Indicators">Indicators</option> <option value="Misc">Misc</option> </select></div>
              <div><label for="product_brand">Product Manufacturer</label> <select id="product_brand" name="product_brand"> <option value="">-- Please select --</option> <option value="Philips">Philips</option> <option value="Osram">Osram</option> <option value="Ring">Ring</option> <option value="Bosch">Bosch</option> <option value="Other">Other</option> </select></div>
              <div class="form-buttons"><input type="submit" value="submit" /></div>
              </form>


              This doesn't do anything.

              If i change the action to this:
              <form class="form" action="[[!my_user_search_form?]]" method="post">


              Then I get taken to the site's home page e.g. mysite.com/No%20POST%20value%20specified

              Using
              <form class="form" action="[[!my_user_search_form?]]" method="get">


              Takes me to the site's home page too, but the url looks like mysite.com/No%20POST%20value%20specified?qwe=0&keyword=&product_category=Headlights&product_brand=Osram

              [ed. note: x0149128 last edited this post 14 years, 5 months ago.]
                • 15083
                • 697 Posts
                Your action is wrong, it should read:
                <form class="form" action="[[~[[*id]]]]" method="POST">
                  • 38004
                  • 96 Posts
                  I tried that one, but nothing happens on clicking search. The page refreshes, the URL stays the same.

                  Just to confirm this is what I have on page:

                  <form class="form" action="[[~[[*id]]]]" method="POST">
                  <div><label for="qwe">Search for products</label>
                  <div id="cat_tree_0" style="display: none;"> </div>
                  <input id="qwe" type="hidden" name="qwe" value="0" />
                  <div id="sel_place"> </div>
                  </div>
                  <div><label for="name">Keyword</label> <input id="name" type="text" name="keyword" /></div>
                  <div><label for="product_category">Product category</label> <select id="product_category" name="product_category"> <option value="">-- Please select --</option> <option value="Headlights">Headlights</option> <option value="HIDs">HIDs</option> <option value="Sidielights">Sidielights</option> <option value="Brake lights">Brake lights</option> <option value="Indicators">Indicators</option> <option value="Misc">Misc</option> </select></div>
                  <div><label for="product_brand">Product Manufacturer</label> <select id="product_brand" name="product_brand"> <option value="">-- Please select --</option> <option value="Philips">Philips</option> <option value="Osram">Osram</option> <option value="Ring">Ring</option> <option value="Bosch">Bosch</option> <option value="Other">Other</option> </select></div>
                  <div class="form-buttons"><input type="submit" value="submit" /></div>
                  </form>
                  <p> </p>
                  <p> </p>
                  
                  [[!my_user_search_form? &post_var_name='product_category' ]]
                  
                  [[!getResources? &parents=`21` &tpl=`product_list` &includeTVs=`1` &processTVs=`1` &tvPrefix=`` &showHidden=`1` &tvFilters='product_name=[[!my_user_search_form? &post_var_name='name' ]]' ]]