Javascript setting a textbox font to italic

I don't have my code in front of me but I am using the GetElementID()...I have code that is setting a textbox to readonly = true, now I also want to change the font of the textbox to Italic...how do I do this?
cenetadminAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

MorcalavinCommented:

document.getElementById('yourtextboxid').style.fontStyle = 'italic';

Open in new window

0
ajitha75Commented:
Try this....

document.getElementById("label1").setAttribute("style","font-style: italic");
0
hieloCommented:
try:
obj.style.fontStyle='italic';

where obj is a reference to the element you get from GetElementID()
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

cenetadminAuthor Commented:
I don't have my code in front of me...but it seems like I am doing some sort of Write statement for all of the javascript lines...how would it effect the syntax?...sorry, can't remember the syntax of the 'write'.
0
hieloCommented:
you mean something like:
document.write("<input type='text' value='hello' style='font-style:italic;'/>")

Open in new window

0
princeatapiCommented:
document.getElementById("tBox").style.fontStyle ="Italic"
0
MorcalavinCommented:
Hard to say without the code.  Can't tell if you are writing out javascript or html elements.  If it was javascript it would look something like this:


document.write("<script type=\"text/javascript\">document.getElementById('textbox').style.fontStyle = 'italic';<\/script>");

Open in new window

0
cenetadminAuthor Commented:
here is a sample line where I am setting the field as readonly...

            s.AppendFormat("    document.getElementById('{0}').readOnly = false;\n", Me.txtPropertyInfo_Taxes_DueYear1_MF.ClientID)
0
MorcalavinCommented:
I'm assuming s is a stringbuilder?

s.AppendFormat("    document.getElementById('{0}').style.display = 'italic';\n", Me.txtPropertyInfo_Taxes_DueYear1_MF.ClientID)

Open in new window

0
MorcalavinCommented:
Woops.  should be this:

s.AppendFormat("    document.getElementById('{0}').style.fontStyle = 'italic';\n", Me.txtPropertyInfo_Taxes_DueYear1_MF.ClientID)

Open in new window

0
cenetadminAuthor Commented:
thanks, will try later this evening and reward if it works. Thanks
0
hieloCommented:
try:
  s.AppendFormat("    document.getElementById('{0}').readOnly = false; document.getElementById('{0}').style.fontStyle='italic'; \n", Me.txtPropertyInfo_Taxes_DueYear1_MF.ClientID)
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
MorcalavinCommented:
Just out of curiosity, why didn't you split the points?  hielo and my code was pretty much the same, with the exception of the script being appended to the same line, instead of two?
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JavaScript

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.