| Author |
setting attribute to input type in javascript
|
prajapatisagar Sagar
Ranch Hand
Joined: Feb 28, 2011
Posts: 35
|
|
below is code written in js the setAttribute is working for type name id size but the other properties it uses does not help
any body please help
var input_itemDesc= document.createElement("input");
input_itemDesc.setAttribute("type", "text");
input_itemDesc.setAttribute("name", "itemDesc"+category_id);
input_itemDesc.setAttribute("id", "itemDesc"+category_id);
input_itemDesc.setAttribute("size", "40");
input_itemDesc.setAttribute("readonly","");
input_itemDesc.setAttribute("class","input-nobox");
thanks in advance
|
 |
Darryl Burke
Bartender
Joined: May 03, 2008
Posts: 4163
|
|
|
Moved from 'Other JSE/JEE APIs'
|
luck, db
There are no new questions, but there may be new answers.
|
 |
Tim McGuire
Ranch Hand
Joined: Apr 30, 2003
Posts: 819
|
|
try capitalizing the O in readOnly:
|
 |
prajapatisagar Sagar
Ranch Hand
Joined: Feb 28, 2011
Posts: 35
|
|
Tim McGuire wrote:try capitalizing the O in readOnly:
It work after
input_itemDesc.setAttribute("readOnly","readOnly");
thanks but what abt the class setting it to input-nobox
|
 |
prajapatisagar Sagar
Ranch Hand
Joined: Feb 28, 2011
Posts: 35
|
|
Bear Bibeault wrote:
prajapatisagar Sagar wrote:thanks but what abt the class setting it to input-nobox
Please use real words when posting to the forums. Abbreviations such as "abt" in place of "about" only serve to make your posts more difficult to read and less likely to generate useful responses.
Please click this link ⇒ UseRealWords for more information.
sorry for that but did you get my problem i want to set attribute of input box class as input-nobox
please reply
|
 |
Tim McGuire
Ranch Hand
Joined: Apr 30, 2003
Posts: 819
|
|
prajapatisagar Sagar wrote:
did you get my problem i want to set attribute of input box class as input-nobox
The syntax for that is correct. are you sure it can find a class "input-nobox" ? Post your css and please use code tags.
|
 |
Eric Pascarello
author
Rancher
Joined: Nov 08, 2001
Posts: 15357
|
|
When using setAttribute, it is className not class.
Eric
|
 |
prajapatisagar Sagar
Ranch Hand
Joined: Feb 28, 2011
Posts: 35
|
|
Eric Pascarello wrote:When using setAttribute, it is className not class.
Eric
THanks eric you solved my problem what a silly mistake
|
 |
Eric Pascarello
author
Rancher
Joined: Nov 08, 2001
Posts: 15357
|
|
prajapatisagar Sagar wrote:
THanks eric you solved my problem what a silly mistake
Not a silly mistake, that is a quirk in JavaScript.
Eric
|
 |
 |
|
|
subject: setting attribute to input type in javascript
|
|
|