470,636 Members | 1,970 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,636 developers. It's quick & easy.

border properties...

hey all,

i have this line of code:

document.getElementById("MESSAGE").innerHTML = total + " out of 24";

total is a variable that calculates the number of characters typed into a field. i need to have a red box appear around the total + " out of 24" if the total is > 24. here's what i have so far:

if ( total > 24 )
{
document.getElementById("MESSAGE").innerHTML = "<span style='border: 1px solid red; padding: .5em>" total + " out of 24</span>";
}
else
{
document.getElementById("MESSAGE").innerHTML = total + " out of 24";
}

this is obviously wrong because when the page loads i lose the "total out of 24" entirely. i'm pretty sure i'm just having syntax issues, but please advise!!

thanks...
Dec 7 '06 #1
4 1467
scripto
143 100+
If "MESSAGE" is a TextBox that could be the problem. Instead of a Texbox, try using a <DIV> - that will handle the innerHTML
Dec 7 '06 #2
If "MESSAGE" is a TextBox that could be the problem. Instead of a Texbox, try using a <DIV> - that will handle the innerHTML
it actually is a div: <div id="message"><div>
Dec 8 '06 #3
scripto
143 100+
then here you go - this seems to work well

document.getElementById("message").innerHTML = total + " out of 24";
document.getElementById("message").style.border="1 px solid red";
document.getElementById("message").style.padding=" .5em";
Dec 8 '06 #4
then here you go - this seems to work well

document.getElementById("message").innerHTML = total + " out of 24";
document.getElementById("message").style.border="1 px solid red";
document.getElementById("message").style.padding=" .5em";
worked like a dream. thanks!
Dec 8 '06 #5

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

33 posts views Thread by Thomas Mlynarczyk | last post: by
5 posts views Thread by Headless | last post: by
14 posts views Thread by Sheila King | last post: by
5 posts views Thread by Rolf Brauser | last post: by
5 posts views Thread by Tamir Khason | last post: by
31 posts views Thread by jcrouse | last post: by
5 posts views Thread by DiGEnig | last post: by
1 post views Thread by Arpan | last post: by
1 post views Thread by Korara | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.