9 Replies Latest reply: Dec 13, 2012 4:07 AM by Ben Pleysier RSS

    Drop down menu open by default php

    chrischris75

      I have this script for a drop down box which is closed until the user clicks the down arrow, showing the options. I want it so all the options are displayed from the start, so they don't have to select the down arrow. Does anyone know what i need to change in order to achieve this? (I think it has something to do with the 'explode' function?)

        • 1. Re: Drop down menu open by default php
          Ben Pleysier CommunityMVP

          I assume that you are talking about a drop down menu, where you click the main menu item to uncover the sub-menu items.

           

          If so, then the code that you have received will most likely be written in server side script, presumably JavaScript.

           

          The code that you are showing is PHP which is a server side script. Which means that if a condition is met, the instruction has to go to the server to be interpreted, upon which it will be sent back to the browser which will refresh with the new information.

           

          Is that what you want? Please elaborate.

          • 2. Re: Drop down menu open by default php
            chrischris75 Community Member

            Yes, i mean a drop down menu. This is the entire code: http://pastebin.com/sya8auVG

            Is there a way i can make it display all the options by default, rather than the user having to click a button to display the options?

            • 3. Re: Drop down menu open by default php
              Ben Pleysier CommunityMVP

              I think you may have shown the wrong code. The code in the pastebin shows a number of checkboxes and no dropdown menubar.

               

              I am going to make another assumption here by saying that I am dealing with a newbie.

               

              For us to help you, we need to have the whole picture. The best way to give us that picture is to upload the site and supply us with a link to that site and, because you are using serverside code (presumably not of your own making) tell us where you obtained the code.

              • 4. Re: Drop down menu open by default php
                chrischris75 Community Member

                The site is here: http://boosterads.co.uk/newsite/ad-category/animals/ It's the 'countys' field on the right hand side in the 'refine results' widget -  i need it to show the entire list of fields without the user having to click on the arrow.

                • 5. Re: Drop down menu open by default php
                  Ben Pleysier CommunityMVP

                  The PHP loads the info from a database to the checkboxes.

                   

                  JavaScript handles the opening and closing of the search box and is handled on lines 263-279 of your document as follwos

                  <script type="text/javascript">

                  // <![CDATA[

                  // toggles the refine search field values
                  jQuery(document).ready(function($) {
                  $('div.handle').click(function() {
                  $(this).next('div.element').animate({
                  height: ['toggle', 'swing'],
                  opacity: 'toggle' }, 200
                  );

                  $(this).toggleClass('close', 'open');
                  return false;
                  });

                  });
                  // ]]>
                  </script>

                  The highlighted line tells the click event to open and close the search box. Try toggling 'open' and 'open' and see what happens

                  • 6. Re: Drop down menu open by default php
                    chrischris75 Community Member

                    ah, i'm with you now. thank you. although i've changed it to 'open' and 'open' but still no joy.

                    • 7. Re: Drop down menu open by default php
                      Ben Pleysier CommunityMVP

                      Change lines 59 and 60 in your document as in

                      <!-- Dynamic Widgets v1.5.3 by QURL - http://www.qurl.nl //-->

                      </head>

                      to

                      <!-- Dynamic Widgets v1.5.3 by QURL - http://www.qurl.nl //-->

                      <style>

                      .element {display: block !important;}

                      </style>

                      </head>

                      by adding the highlighted code including the !important bit.

                       

                      This will override the JS which changes the condition dynamically.

                      • 8. Re: Drop down menu open by default php
                        chrischris75 Community Member

                        thanks, although because my script is written in php i can't see the part you quoted.

                        I added:

                        <style>

                        .element {display: block !important;}

                        </style>


                        outside of the php script and it seems to be working at the moment. Was this the right thing to do?

                        The whole script is here: http://pastebin.com/Xq0GaEbu with the added part at line 103.

                        Thank you for all your help too.

                        • 9. Re: Drop down menu open by default php
                          Ben Pleysier CommunityMVP

                          No, strictly speaking it is not in the correct spot.

                           

                          1. Open style.css (newsite/wp-content/themes/classipress/style.css)

                          2. Go to line 136 (.content_right ul.refine li div.element {display:none;})

                          3. Change none to block !important

                          4. Save the file and upload

                          5. In your main document, remove

                          <style>

                          .element {display: block !important;}

                          </style>

                          6. Save your main document and upload

                           

                          The reason I say that it is not in the correct spot, CSS must always be declared in the <HEAD> section of your document. In my previous post you will see the ending HEAD tag (</head>) and my apologies for not having thought of the fact that you would have PHP code in your document that would influence the numbering of the lines.