Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

DHTML and Java Script

eniasmbeniasmb Member Posts: 3
Iam a new start to programming. Could someone please explain with good examples how DHTML is used with Java Script?

I would appreciate the explanation.

EM
London

Comments

  • richard_wise25richard_wise25 Member Posts: 52
    DHTML is simply Dynamic HTML. The Dynamic bit refers to the fact that in DHTML, you use JavaScript to change the source code of the page, and the change is shown without refreshing the page. Look at this program, it changes background color every .25 seconds.




    var level = 0;
    function dec_hex(x) {
    switch (x) {
    case 10: return ('A');
    break;
    case 11: return ('B');
    break;
    case 12: return ('C');
    break;
    case 13: return ('D');
    break;
    case 14: return ('E');
    break;
    case 15: return ('F');
    break;
    default: return x;
    }
    }
    function changecolor() {
    colorstr1 = document.bgColor;
    if(colorstr1.substring(1, 2)=='f') { level=3; }
    if(colorstr1.substring(3, 4)=='f') { level=4; }
    if(colorstr1.substring(5, 6)=='f') { level=5; }
    switch(level) {
    case 0: colorstr2=dec_hex(parseInt(colorstr1.substring(1, 2), 16)+1)+''+dec_hex(parseInt(colorstr1.substring(2, 3), 16)+1)+'0000';
    break;
    case 1: colorstr2='00' + dec_hex(parseInt(colorstr1.substring(3, 4), 16)+1)+''+dec_hex(parseInt(colorstr1.substring(4, 5), 16)+1)+'00';
    break;
    case 2: colorstr2='0000' + dec_hex(parseInt(colorstr1.substring(5, 6), 16)+1)+''+dec_hex(parseInt(colorstr1.substring(6, 7), 16)+1);
    break;
    case 3: colorstr2='000000'; level+=-2;
    break;
    case 4: colorstr2='000000'; level+=-2;
    break;
    case 5: colorstr2='000000'; level+=-5;
    break;
    }
    document.bgColor=colorstr2;
    setTimeout("changecolor()", 250); //sets it to change color every 0.25 sec
    }






Sign In or Register to comment.