This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
The moose likes HTML, CSS and JavaScript and the fly likes setting attribute to input type in javascript Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "setting attribute to input type in javascript " Watch "setting attribute to input type in javascript " New topic
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: 4642
    
    5

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: 820

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: 820

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: 15376
    
    6
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: 15376
    
    6
prajapatisagar Sagar wrote:
THanks eric you solved my problem what a silly mistake


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

Eric
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: setting attribute to input type in javascript