SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Enthusiast
    Join Date
    Apr 2002
    Posts
    90
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    select - hide, show div

    There is a form select tag and div.
    Is it possible to hide or show div depending on what options selected

    If selected two or with id "non_able"- hide
    if selected with id "able" - show


    HTML Code:
    <SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript">
    <!--
    function ShowHelp(div) {
      var div = document.getElementById(div);
      div.style.display = 'inline';
    }
    function HideHelp(div) {
     var div = document.getElementById(div);
     div.style.display = 'none';
    }
    
    function DivState(select_id, div) {
     
     var select_tag = document.getElementById(select_id);
     
     if(select_tag.selectedIndex == -1) {
      HideHelp(div);
     }
    
     ........
    
    //-->
    </SCRIPT>
     
    <select name="my_select[]" id="my_select" size="3" multiple onChange="DivState('my_select', 'my_div')">
     <option value="1" id="able">1</option>
     <option value="2" id="non_able">2</option>
     <option value="3" id="able">3</option>
    </select>
     
    <div id="my_div" style="DISPLAY: none;">654654656546565</DIV>

  2. #2
    SitePoint Wizard silver trophy rushiku's Avatar
    Join Date
    Dec 2003
    Location
    A van down by the river
    Posts
    2,056
    Mentioned
    0 Post(s)
    Tagged
    1 Thread(s)
    Code:
    if( select_tag.options[select_tag.selectedIndex].id  == 'able' ) {
      showHelp(div);
    }


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •