Javascript Textbox border issue

J

john

I'm adding a Textbox with javascript, it works except for the border
attribute, any advive
Thanks
John

var formFld = document.createElement('input')

formFld.setAttribute('type', 'text')

formFld.setAttribute('id', txt)

formFld.value = document.getElementById(lb).innerHTML

formFld.name = txt

formFld.setAttribute('width','30')

formFld.setAttribute('border', '3px solid #FF0000')
 
N

Norm

I'm adding a Textbox with javascript, it works except for the border
attribute, any advive
Thanks
John

var formFld = document.createElement('input')

formFld.setAttribute('type', 'text')

formFld.setAttribute('id', txt)

formFld.value = document.getElementById(lb).innerHTML

formFld.name = txt

formFld.setAttribute('width','30')

formFld.setAttribute('border', '3px solid #FF0000')

John,
That last line is setting the html attribute of "border" (which I'm
pretty sure doesn't exist on textbox) to a CSS value.
A simple correction would be:

formFld.setAttribute('style', 'border: 3px solid #FF0000;')

Although, I'm not actually sure this would work. I would instead
suggest using the style property as such:

formFld.style.border = '3px solid #FF0000'

Reference: http://www.w3schools.com/htmldom/dom_obj_style.asp#border

Hope This helps!
Norm
 
J

john

Thanks your last method worked.
John

I'm adding a Textbox with javascript, it works except for the border
attribute, any advive
Thanks
John

var formFld = document.createElement('input')

formFld.setAttribute('type', 'text')

formFld.setAttribute('id', txt)

formFld.value = document.getElementById(lb).innerHTML

formFld.name = txt

formFld.setAttribute('width','30')

formFld.setAttribute('border', '3px solid #FF0000')

John,
That last line is setting the html attribute of "border" (which I'm
pretty sure doesn't exist on textbox) to a CSS value.
A simple correction would be:

formFld.setAttribute('style', 'border: 3px solid #FF0000;')

Although, I'm not actually sure this would work. I would instead
suggest using the style property as such:

formFld.style.border = '3px solid #FF0000'

Reference: http://www.w3schools.com/htmldom/dom_obj_style.asp#border

Hope This helps!
Norm
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,172
Messages
2,570,934
Members
47,478
Latest member
ReginaldVi

Latest Threads

Top