Results 1 to 3 of 3

Thread: How set the value of an HTML (not form) element using Javascript?

  1. #1
    Join Date
    Sep 2009

    How set the value of an HTML (not form) element using Javascript?


    How do I set the value (i.e. the contents) of an HTML element (such as p or div) using Javascript? I can't do this using server side (ASP, PHP etc.) because the value is calculated and possibly changed multiple times by user action in the browser. I don't want to use form fields since they look as if the user can enter data into them, even if I set them to read only. There must be a way of doing this using the DOM, but I can't find it...

    Thanks - Rowan

  2. #2
    Join Date
    Dec 2002
    Pleasanton, CA
    element.innerHTML = HTMLtext;

  3. #3
    Join Date
    Jul 2008
    urbana, il
    use .innerHTML instead of .value ...

    or, style the inputs in CSS so they don't look like input (no border, transparent bg, etc).
    Create, Share, and Debug HTML pages and snippets with a cool new web app I helped create: pagedemos.com

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center

Recent Articles