Connecting Tech Pros Worldwide Forums | Help | Site Map

Add Element to Form

MC
Guest
 
Posts: n/a
#1: Jun 27 '08
Hi,

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

<span class="Arial090NN" 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
Guest
 
Posts: n/a
#2: Jun 27 '08

re: Add Element to Form


"MC" <mica[removethis]@aisus.comwrites:
Quote:
Hi,
>
I am looking to programmatically add an element to a form, in this case a
SPAN message.
>
<span class="Arial090NN" 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.getElementById("id-of-form");
// or
var form = document.forms["name-of-form"];

var span = document.createElement("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.color="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.appendChild(document.createTextNode("My Message");

form.appendChild(span);


--
Joost Diepenmaat | blog: http://joost.zeekat.nl/ | work: http://zeekat.nl/
MC
Guest
 
Posts: n/a
#3: Jun 27 '08

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.nlwrote in message
news:87ve1gmwpu.fsf@zeekat.nl...
Quote:
"MC" <mica[removethis]@aisus.comwrites:
>
Quote:
>Hi,
>>
>I am looking to programmatically add an element to a form, in this case a
>SPAN message.
>>
><span class="Arial090NN" 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.getElementById("id-of-form");
// or
var form = document.forms["name-of-form"];
>
var span = document.createElement("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.color="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.appendChild(document.createTextNode("My Message");
>
form.appendChild(span);
>
>
--
Joost Diepenmaat | blog: http://joost.zeekat.nl/ | work: http://zeekat.nl/

Closed Thread