Javascript div hide/show problem in IE

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Chittaranjan
    New Member
    • Sep 2006
    • 51

    Javascript div hide/show problem in IE

    Hi All,

    I am having a problem using Javascript in Perl script. In the perl module I have included the Javascript codes and that is workign fine for validation purpose but when I am trying to show and hide some divisions randomly selecting from a drop down menu then that is working fine in Mozilla but not working in IE 6/7. Here is some part of my code: if any suggestions please welcome...

    Thanks,
    Chittaranjan

    This is the Javascript code I am using for div hiding and showing
    Code:
    <script type="text/javascript">
    <!--
    function showOptionals(field) {
    	var loc = document.getElementById('noOfItems').value;
    	for ( i = 1; i <= loc; i++ ) {
    		var sel = document.getElementById('sel-tlcode-'+i).value;
    		if ( i == sel ) {
    			document.getElementById(i).style.display='block';
    		}
    		else {
    			document.getElementById(i).style.display='none';
    		}
    	}
    }
    //-->
    </script>
    This is the perl script drop down where I am calling the Javascript function
    Code:
    print popup_menu(
    	-name		=> 'sel-tlcode-' . $y,
    	-id			=> 'sel-tlcode-' . $y,
    	-value		=> \@xx,
    	-default	=> $value{$label},
    	-class		=> ( $errLabel eq $label ) ? 'formmsg' : 'formelements',
    	-title		=> 'Select a location code that corresponds with a location list in the section below.',
    	-tabindex	=> $tabindex,
    	-onChange	=> "showOptionals(this);",
    	-force		=> 1
    );
    This is the div which I want to show and hide randomly selecting from the drop down.....
    Code:
    print "<div id=".$a." style=\"display:none\">";
  • miller
    Recognized Expert Top Contributor
    • Oct 2006
    • 1086

    #2
    (Moving thread to Javascript from Perl)

    Hello Chittaranjan,

    I understand that this html was generated using perl, but the nature of your problem is in the JavaScript, not the perl that is generating it.

    I have a feeling that our friendly Javascript experts might need more information from you, but I'll let them ask if that's so.

    - Miller

    Comment

    • acoder
      Recognized Expert MVP
      • Nov 2006
      • 16032

      #3
      Maybe you have not closed your div?

      Comment

      Working...