Skip navigation
Currently Being Moderated

Drop down menu open by default php

Dec 12, 2012 1:54 AM

Tags: #php

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?)

<?php

                              $options = explode(',', $values);

                              $optionCursor = 1;

                              $checked = '';

                              ?>

 

 
Replies
  • Currently Being Moderated
    Dec 12, 2012 2:08 AM   in reply to chrischris75

    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.

     
    |
    Mark as:
  • Currently Being Moderated
    Dec 12, 2012 2:38 AM   in reply to chrischris75

    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.

     
    |
    Mark as:
  • Currently Being Moderated
    Dec 12, 2012 3:08 AM   in reply to chrischris75

    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

     
    |
    Mark as:
  • Currently Being Moderated
    Dec 12, 2012 3:55 PM   in reply to chrischris75

    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.

     
    |
    Mark as:
  • Currently Being Moderated
    Dec 13, 2012 4:07 AM   in reply to chrischris75

    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.

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points