We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 22574
    • 181 Posts
    Hey All,

    I am wondering if there is an easy way to send a select boxs value to a snippet.

    &dropdown=`[*option_1*]`
    option_1 begin the name of the select box.

    And then in the snippet: $dropdown = isset($dropdown) ? $dropdown : ’yellow’;

    So this works if I use a TV or just a string.

    But how do I send the option that has been click from a dropdown list?
      • 34193
      • 330 Posts
      Are these values coming from an HTML form or as URL parameters if so they will be available inside the snippet via the usual PHP $_GET or $_POST.

      Somthing inside your snippet like
      <?php
      $dropdown = isset($_POST['dropdown']) ? $_POST['dropdown'] : 'yellow';
      ?>
      

      Would do the job.

      Beyond that I don’t think you can since snippets are called from within HTML and not PHP and so variable values are not accessable.
        • 22574
        • 181 Posts
        Thanks but I think I need to provide more as its probably more complicated than I thought.


        I am actually trying to send TreasureChest the value.

        Here is the call: [[TreasureChest? &item=`[+placeholdername+]` &selector=`item_name` &dropdown=`[*option_1*]`]]

        The select menu: [+placeholderDropdownName+] [+placeholderDropdownValue+]

        Here is the link that adds a product: <a href="#" onclick="return false;" class="treasureChest" title="[+placeholdername+]" name="[+placeholdername+]" rel="item_name">Add to Cart</a>

        This link I dont really get, I understand how the return false stops the url going to # but I dont get how treasurechest is triggered?

        How can I trigger the ’Add to Cart’ and add the dropdown menus value.
          • 34193
          • 330 Posts
          OK never used treasure chest sorry, I would still ask where the dropdown info is coming from. I can’t thing of a way in EVO that you could get the value from a form and feed it in as a parameter to a snippet, only accessing it from with the snippet.

          The reasoning for this has nothing to do with MODX or TreasureChest it’s to do with the way HTML and PHP opperate. If it was on REVO then you could use a snippet as the input to the parameter but I don’t think EVO allows nested snippets, this may have changed been awhile since I used it.

          EDIT Can you paste your html and snippet code this would let me see better what you are trying to do.
            • 22574
            • 181 Posts
            No probs,

            Thanks for the help!

            Kinda worked out how TC passes the values to the php script.