We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 14344
    • 16 Posts
    I’m trying to create a drop down list that inputs the tag value. So only the selected item in the list is displayed in the ditto call.
    The problem with this code is when you select an item out of the list it takes you to url www.mywebsite.com/speaker1(the value selected). so how can I get this to select a value that the ditto call can read?

    So far this is my codding:
    <FORM name="speaker">
    <SELECT name="speakername" id="speakername2" onchange="location = this.options[this.selectedIndex].value;">
    <OPTION selected="selected" value="speaker1">speaker1</option>
    <OPTION value="speaker2">speaker2</option>
    </SELECT>

    [!Ditto? &parents=`5` &level=`0` &tpl=`SermonDitto` &display=`10` &paginate=`1` &paginateAlwaysShowLinks=`0` &tagDelimiter=`,` &tagData=`tvSpeaker` &tagMode=`onlyAllTags` &tags=`[+speakername2+]`!]
    [+previous+] - [+pages+] - [+next+]
      • 3749
      • 24,544 Posts
      I don’t think speakername will be available as a placeholder.

      I think you’ll need to use a snippet tag there as a parameter in the Ditto call instead.

      [!GetSpeakername!]


      Then in your GetSpeakername snippet:

      return $_POST['speakername'];
        Did I help you? Buy me a beer
        Get my Book: MODX:The Official Guide
        MODX info for everyone: http://bobsguides.com/modx.html
        My MODX Extras
        Bob's Guides is now hosted at A2 MODX Hosting
        • 14344
        • 16 Posts
        BobRay thanks for the help.

        But I must be missing something. I still get the 404(tries to go to website url/speaker value) page if I change the drop down list selection, and the ditto call doesn’t seem to be receiving any kind of value. Isn’t there an easy way of sorting/tagging with a drop down list/menu? It has been done on the modx showcase page http://modxcms.com/learn/showcase/?view=tag&tag=16. All I need is a option list that the value selected is the input for the &tags= parameter in the ditto call.

        Thanks again!
          • 3749
          • 24,544 Posts
          I guess I’m not clear on what you’re trying to do. AFAIK, when using the JS location=, each option needs to be a URL that the browser will jump to. Do you intend to jump to another page or the current page?

          If the Ditto call is on the curent page, it will execute when the page is first visited -- before the user has selected any option.



            Did I help you? Buy me a beer
            Get my Book: MODX:The Official Guide
            MODX info for everyone: http://bobsguides.com/modx.html
            My MODX Extras
            Bob's Guides is now hosted at A2 MODX Hosting
            • 14344
            • 16 Posts
            It needs to be the current page. I just want the form select field to be selecting different options and that value of the selected option become the $tags= parameter for the ditto.
              • 16278
              • 928 Posts
              I’m not too sure about the Javascript, but you need the tags to be selected via the URL query string, not as a parameter in the Ditto call. So you have to cut the &tags parameter from the call, and the URL would look like www.mysite.com/speakers.html?tags=speaker2 when you select speaker 2 from the list.
              smiley KP
                • 4310
                • 2,310 Posts
                Something like this should work :
                <script type="text/javascript" language="JavaScript">
                function nav()
                   {
                   var w = document.qsearch.xfer.selectedIndex;
                   var url_add = document.qsearch.xfer.options[w].value;
                   window.location.href = url_add;
                   }
                </script>
                <form id="qsearch" name="qsearch">
                <fieldset id="qsearch">
                <select name="xfer" size="1" onChange="nav()">
                <option selected value="Select speaker...">Select speaker...</option>
                <option value="[~99~]?tags=A.Brown">A.Brown</option>
                <option value="[~99~]?tags=B.Smith">B.Smith</option>
                <option value="[~99~]?tags=C.Jones">C.Jones</option>
                </select>
                </fieldset>
                </form>
                

                Where 99 is the id of the document with the Ditto call.
                  • 14344
                  • 16 Posts
                  The problem with that is it leads me back to the home page. So I have to change anything is modx to allow added strings in the url?

                  Thanks all for the help!
                    • 14344
                    • 16 Posts
                    I got it! after some searching on modx forums I found out that because I’m not using friendly urls I needed to replace the ? with & so there wasn’t 2 ?...

                    Thanks Bobray, kp52, and bunk58.
                      • 3749
                      • 24,544 Posts
                      Glad you got it sorted. Thanks for reporting back. smiley
                        Did I help you? Buy me a beer
                        Get my Book: MODX:The Official Guide
                        MODX info for everyone: http://bobsguides.com/modx.html
                        My MODX Extras
                        Bob's Guides is now hosted at A2 MODX Hosting