Web Analytics Made Easy -
StatCounter using OnPageLoad / Window.onload - CodingForum

Announcement

Collapse
No announcement yet.

using OnPageLoad / Window.onload

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • using OnPageLoad / Window.onload

    Hello, i'm trying to get this script to display the "blank" category (div layer) upon page load.


    On my display page i have :


    <SCRIPT type=text/javascript>
    var keywords = new Array("blank","Logos","Posters");
    </SCRIPT>

    <SCRIPT src="java/showkeywords.js"
    type=text/javascript></SCRIPT>


    With some radio buttons like this:
    <INPUT onclick="show('Logos')" type=radio name=pick>
    <INPUT onclick="show('Posters')" type=radio name=pick>


    And div layers like this:

    <DIV id=blank> blank </div>
    <DIV id=logos> logos </div>
    <DIV id=posters> posters </div>


    my JS page looks like this:


    function show(keyword) {
    if (keyword=="All") {
    for (i=0; i < keywords.length; i++) {
    document.getElementById(keywords[i]).style.display="block";
    }
    }
    else {
    for (i=0; i < keywords.length; i++) {
    document.getElementById(keywords[i]).style.display="none";
    }
    document.getElementById(keyword).style.display="block";
    }
    }




    thanks a lot for any help possible, i've tried everything my simple CFBrain can handle

  • #2
    Try this:
    Code:
    <script type="text/javascript">
      function show(keyword){
       var keywords = new Array('blank','logos','posters');
        for(var i=0; i<keywords.length; i++){
         var which = document.getElementById(keywords[i]);
          if(document.forms[0].all.checked == true){
             which.style.display='block'};
             else{which.style.display='none'};
    
          if(keyword == keywords[i]){
            (which.style.display='block') ? 'none':'block'};
        }
      } 
    </script>
    </HEAD>
    
    <BODY onload="show('blank')">
    <form>
    <input onclick="show('logos')" type="radio" name="pick"> Logos
    <input onclick="show('posters')" type="radio" name="pick"> Posters
    <input onclick="show('all')" type="checkbox" name="all"> Show/Hide All
    </form>
    
    <div id="blank" style="display:none"> blank </div>
    <div id="logos" style="display:none"> logos </div>
    <div id="posters" style="display:none"> posters </div>
    .....Willy

    Comment


    • #3
      willy didit -

      thanks a million, that worked great willy, i really appreciate it

      Comment

      Working...
      X