Javascript Textbox border issue

  • Thread starter Thread starter john
  • Start date Start date
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')
 
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
 
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
 
Back
Top