Add Element to Form

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • MC

    Add Element to Form

    Hi,

    I am looking to programmaticall y add an element to a form, in this case a
    SPAN message.

    <span class="Arial090 NN" style="COLOR: red;LEFT: 85px; TOP: 176px; HEIGHT:
    9px; TEXT-ALIGN: left; Z-INDEX: 100; POSITION: absolute;">My Message</span>

    I've been looking on the web and I've not been able to find this. Any ideas?

    Thanks,
    Mica


  • Joost Diepenmaat

    #2
    Re: Add Element to Form

    "MC" <mica[removethis]@aisus.comwrite s:
    Hi,
    >
    I am looking to programmaticall y add an element to a form, in this case a
    SPAN message.
    >
    <span class="Arial090 NN" style="COLOR: red;LEFT: 85px; TOP: 176px; HEIGHT:
    9px; TEXT-ALIGN: left; Z-INDEX: 100; POSITION: absolute;">My Message</span>
    >
    I've been looking on the web and I've not been able to find this. Any ideas?
    see http://www.w3.org/TR/REC-DOM-Level-1...e-binding.html

    You probably want something like this:

    var form = document.getEle mentById("id-of-form");
    // or
    var form = document.forms["name-of-form"];

    var span = document.create Element("span") ;
    span.className= "Arial090NN "; // if this is what I think it is it's a really
    // stupid class name - class names should be
    // "semantic", not indicative of any particular style


    span.style.colo r="red";
    span.style.left ="85px";
    // etc
    // usually you're better off putting styles in the appropriate class and/or id
    // in a seperate stylesheet anyway


    span.appendChil d(document.crea teTextNode("My Message");

    form.appendChil d(span);


    --
    Joost Diepenmaat | blog: http://joost.zeekat.nl/ | work: http://zeekat.nl/

    Comment

    • MC

      #3
      Re: Add Element to Form

      Joost,

      You be the man! So many times I have needed this.

      I agree on your comments but in this case it fits. This is a very complex
      6-page form with many types of fonts that are standard accross a whole
      library of forms.

      Thank you AGAIN!
      Mica

      "Joost Diepenmaat" <joost@zeekat.n lwrote in message
      news:87ve1gmwpu .fsf@zeekat.nl. ..
      "MC" <mica[removethis]@aisus.comwrite s:
      >
      >Hi,
      >>
      >I am looking to programmaticall y add an element to a form, in this case a
      >SPAN message.
      >>
      ><span class="Arial090 NN" style="COLOR: red;LEFT: 85px; TOP: 176px;
      >HEIGHT:
      >9px; TEXT-ALIGN: left; Z-INDEX: 100; POSITION: absolute;">My
      >Message</span>
      >>
      >I've been looking on the web and I've not been able to find this. Any
      >ideas?
      >
      see http://www.w3.org/TR/REC-DOM-Level-1...e-binding.html
      >
      You probably want something like this:
      >
      var form = document.getEle mentById("id-of-form");
      // or
      var form = document.forms["name-of-form"];
      >
      var span = document.create Element("span") ;
      span.className= "Arial090NN "; // if this is what I think it is it's a
      really
      // stupid class name - class names should be
      // "semantic", not indicative of any
      particular style
      >
      >
      span.style.colo r="red";
      span.style.left ="85px";
      // etc
      // usually you're better off putting styles in the appropriate class
      and/or id
      // in a seperate stylesheet anyway
      >
      >
      span.appendChil d(document.crea teTextNode("My Message");
      >
      form.appendChil d(span);
      >
      >
      --
      Joost Diepenmaat | blog: http://joost.zeekat.nl/ | work: http://zeekat.nl/

      Comment

      Working...