WebFX WebBoard
Message Thread:
View All Messages
Back to WebFX
 Re:Minor JavaScript/DHTML question, dreadcast, September 3, 2003
     Re:Minor JavaScript/DHTML question, Guillermo, September 3, 2003
         Re:Minor JavaScript/DHTML question, Guilherme Blanco, September 3, 2003
             Re:Minor JavaScript/DHTML question, Guillermo, September 3, 2003
                 Re:Minor JavaScript/DHTML question, Guillermo, September 3, 2003
                     Re:Minor JavaScript/DHTML question, Guilherme Blanco, September 3, 2003
         Re:Minor JavaScript/DHTML question, dreadcast, September 3, 2003
             Re:Minor JavaScript/DHTML question, Guilherme Blanco, September 3, 2003
                 Re:Minor JavaScript/DHTML question, dreadcast, September 3, 2003

Subject: Re:Minor JavaScript/DHTML question From: Guillermo Date: September 3, 2003

All I need to figure out now is the skinned check boxes thingies. As you can see from the site, I'm more of a web graphic designer than JScript programmer.

Thanks again for your help.


 

From: Guillermo
Sent: September 3, 2003
Subject: Re:Minor JavaScript/DHTML question

GREAT!

It's working. Thanks a lot for your help.


 

From: Guilherme Blanco
Sent: September 3, 2003
Subject: Re:Minor JavaScript/DHTML question

I re-wrote your function. Seems to be okay now (at least in mine tests).
I should use document.images instead of document.getElementById, defined in DOM Level 1.

Take a look at your function now:
img_down = new Image(); img_down = "down.png";
img_up = new Image(); img_up = "up.png";

function toggleMenu( iNumber ) {
  if( document.getElementById("content"+iNumber).style.display == "block" ) {
    document.images["image"+iNumber].src = img_down;
    document.getElementById("content"+iNumber).style.display = "none";
  } else {
    document.images["image"+iNumber].src = img_up;
    document.getElementById("content"+iNumber).style.display = "block";
  }
}

All you have to do is this: toggleMenu('1');

Take a look at mine example working well in IE and Mozilla:
<HTML>
  <HEAD>
    <TITLE>Test</TITLE>
    <script>
      img_down = new Image(); img_down = "down.png";
      img_up = new Image(); img_up = "up.png";

      function toggleMenu( iNumber ) {
        if( document.getElementById("content"+iNumber).style.display == "block" ) {
          document.images["image"+iNumber].src = img_down;
          document.getElementById("content"+iNumber).style.display = "none";
        } else {
          document.images["image"+iNumber].src = img_up;
          document.getElementById("content"+iNumber).style.display = "block";
        }
      }
      window.onload = function () {
        document.images['image1'].src = img_down;
      }
    </script>
  </HEAD>

  <BODY>
    <a href="#" onclick="toggleMenu('1');"><img name="image1" width="100" height="50"></a>
    <div id="content1" style="display: none;">
      Here is the content!!!
    </div>
  </BODY>
</HTML>


I hope this answers your question.

Cheers,
Guilherme Blanco

From: Guillermo
Sent: September 3, 2003
Subject: Re:Minor JavaScript/DHTML question

Sorry, I don't understand this. Where do I add this code?


 

From: dreadcast
Sent: September 3, 2003
Subject: Re:Minor JavaScript/DHTML question

debe crear una imagen en javascript como esto :

img1 = new image(); 
img1.src = 'path/to/image.ext';

So that the image is in the browser cache.








Reply
Name: 
Email: 
Subject: 

Enter your reply to this message below. HTML tags are not supported but words that start with http://, ftp:// or mailto: are converted to links.


View All Messages
Back to WebFX