reset password
Author Message
clai8
Posts: 8
Posted 20:17 Nov 14, 2014 |

if(result == "S") document.getElementById("scotty").classname="displayme";    //any errors here???

trying to change the img from hidden to display.

setted the display css like this: .displayme{float:right; MARGIN-TOP:4%; MARGIN-RIGHT:2%; border:solid; border-color:purple; display:block; width:413px; height:413px;}

div id = "scotty" and class = "hideme"

 

gjmiles
Posts: 17
Posted 20:57 Nov 14, 2014 |

While javascript does not require curly braces and a new lines with if statements, you should really use them.

For example this:

if(result == "S") document.getElementById("scotty").classname="displayme"; 

Is a lot easier to read if it is like this:

if(result == 'S')
{
document.getElementById("scotty").classname="displayme";
}

Also I am a little confused about what the .classname is supposed to be doing?  If you are using getElementById there is a different method that is available to change the style of the display. (hint hint)

Last edited by gjmiles at 20:59 Nov 14, 2014.
clai8
Posts: 8
Posted 21:02 Nov 14, 2014 |

the class displayme do this: {float:right; MARGIN-TOP:4%; MARGIN-RIGHT:2%; border:solid; border-color:purple; display:block; width:413px; height:413px;}

 

it's in css.

and it suppose to make a pic show on html. The pic is in a div with classid and elementid in HTML.

gjmiles
Posts: 17
Posted 21:06 Nov 14, 2014 |

If you change your .hideme class to display:block; does it show the image?

clai8
Posts: 8
Posted 21:08 Nov 14, 2014 |

never mind. Thanks I solved the problem. lol I put the javascript first and put the div after. so i display it and hide it back again. == sigh....... I am stupid .....