• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

setting attribute to input type in javascript

 
prajapatisagar Sagar
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 5125
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moved from 'Other JSE/JEE APIs'
 
Tim McGuire
Ranch Hand
Posts: 820
IntelliJ IDE Tomcat Server VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
try capitalizing the O in readOnly:

 
prajapatisagar Sagar
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 820
IntelliJ IDE Tomcat Server VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When using setAttribute, it is className not class.

Eric
 
prajapatisagar Sagar
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
prajapatisagar Sagar wrote:
THanks eric you solved my problem what a silly mistake


Not a silly mistake, that is a quirk in JavaScript.

Eric
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic