[Solved] If Else Show Hide Div menu

Shout-Out

User Tag List

Results 1 to 1 of 1
  1. #1
    DoxramosPS's Avatar Knight
    Reputation
    26
    Join Date
    Aug 2010
    Posts
    214
    Thanks G/R
    0/4
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    [Solved] If Else Show Hide Div

    I'm trying to get an option in my vote store that I'm working on to show/hide pet information based off an else if statement.
    My Selection base is as follows.
    PHP Code:
    <select onchange="optionCheck()" id="pets" name ="pets">
            <?php
            $get_vote_pets 
    mysql_query("SELECT * FROM $server_db.pet_rewards WHERE price =10");
                    while(
    $results mysql_fetch_array($get_vote_pets)){
                    echo 
    '<option value="'.$results['id'].'">'.$results['name'].' '.$results['id'].'</option>';
                    }
                    
    ?>
            </select>
    Underneath that I then have my Divs
    PHP Code:
    <div id="monk1" style=visibility:hidden>Text A</div>
    <
    div id="monk2" style=visibility:hidden>Text B</div
    And then in the header of my file I have
    PHP Code:
    <script type="text/javascript">
        function 
    optionCheck(){
            var 
    option document.getElementById("pets").value;
            if(
    option == "67"){
                
    document.getElementById("panda1").style.visibility ="visible";
                
    document.getElementById("panda2").style.visibility ="hidden";
            }
            if(
    option == "66"){
                
    document.getElementById("panda2").style.visibility ="visible";
                
    document.getElementById("panda1").style.visibility ="hidden";
            }
        }
    </script> 
    The ID for the first and second item in the database are 66 and 67 and having them show in the option selection it shows the id as such.
    Yet when I try to run the page the divs remain hidden no matter what the selection is.
    If anyone could help please do. If you need more info need only ask. I think this should cover it though.

    document.getElementById("panda2").style.visibility ="visible";
    document.getElementById("panda1").style.visibility ="hidden";
    Should have been monk1 and monk2; I noticed as soon as I posted. Flame away >.>
    Last edited by DoxramosPS; 02-25-2013 at 05:49 PM. Reason: solved
    Mangos and Trinity Emulation
    Windows | Linux
    Under Development : morgangreen.org WoW CMS Site

    [Solved] If Else Show Hide Div

Similar Threads

  1. Further Regards to showing div.
    By DoxramosPS in forum Programming
    Replies: 0
    Last Post: 02-25-2013, 06:10 PM
  2. PHP If Else on Div.
    By DoxramosPS in forum Programming
    Replies: 2
    Last Post: 02-24-2013, 06:12 PM
  3. [Question] "Hide" some divs from the source
    By Achi3 in forum Programming
    Replies: 11
    Last Post: 11-24-2009, 02:09 PM
  4. [show off]Something else.. :]
    By Gawdlaw in forum Art & Graphic Design
    Replies: 9
    Last Post: 08-16-2009, 05:26 AM
All times are GMT -5. The time now is 12:43 PM. Powered by vBulletin® Version 4.2.3
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved. User Alert System provided by Advanced User Tagging (Pro) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
Google Authenticator verification provided by Two-Factor Authentication (Free) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
Digital Point modules: Sphinx-based search