Hello,
I need to know how to create closing tag elements when using DOM to add in form elements to a page.
Here is the code...the <div> I am adding to the page is called dropDownList (for legacy reasons...it isnt really a drop down list!).
I need to put in closing td tags...
I tried this:
[CODE=javascript] var tdClose = document.create Element(/td);[/CODE]
and this:
[CODE=javascript] var td = document.create Element('/td');[/CODE]
but when I try and add them e.g.
[CODE=javascript]document.getEle mentById('dropD ownList').appen dChild(tdClose) ;[/CODE]
I get errors.
Help !
[CODE=javascript]function addRaresToList( number){
var species = document.getEle mentById('addSp ecies').value;
alert ("ADD " + species + " to " + number);
var td = document.create Element(td);
// add hidden index
var i = document.create Element('input' );
i.type = 'hidden';
i.name = 'observation.in dex';
i.value = 'number';
document.getEle mentById('dropD ownList').appen dChild(i);
// add hidden comment
var i = document.create Element('input' );
i.type = 'hidden';
i.name = 'observation.nu mber.comment';
i.id = 'observation.nu mber.comment';
document.getEle mentById('dropD ownList').appen dChild(i);
// add hidden breeding code
var i = document.create Element('input' );
i.type = 'hidden';
i.name = 'observation.nu mber.breedingCo de';
i.id = 'observation.nu mber.breedingCo de';
document.getEle mentById('dropD ownList').appen dChild(i);
// add species name
document.getEle mentById('dropD ownList').appen dChild(td);
var txt = document.create TextNode(specie s);
document.getEle mentById('dropD ownList').appen dChild(txt);
// add checkbox
document.getEle mentById('dropD ownList').appen dChild(td);
var i = document.create Element('input' );
i.type = 'checkbox';
i.name = 'observation.nu mber.species';
var d = document.getEle mentById( 'dropDownList' );
d.appendChild( i );
// add textbox
document.getEle mentById('dropD ownList').appen dChild(td);
var i = document.create Element('input' );
i.type = 'text';
i.name = 'observation.nu mber.speciesCod e';
i.size = '7';
i.maxlength = '7';
var d = document.getEle mentById( 'dropDownList' );
d.appendChild( i );
}
</script>[/CODE]
I need to know how to create closing tag elements when using DOM to add in form elements to a page.
Here is the code...the <div> I am adding to the page is called dropDownList (for legacy reasons...it isnt really a drop down list!).
I need to put in closing td tags...
I tried this:
[CODE=javascript] var tdClose = document.create Element(/td);[/CODE]
and this:
[CODE=javascript] var td = document.create Element('/td');[/CODE]
but when I try and add them e.g.
[CODE=javascript]document.getEle mentById('dropD ownList').appen dChild(tdClose) ;[/CODE]
I get errors.
Help !
[CODE=javascript]function addRaresToList( number){
var species = document.getEle mentById('addSp ecies').value;
alert ("ADD " + species + " to " + number);
var td = document.create Element(td);
// add hidden index
var i = document.create Element('input' );
i.type = 'hidden';
i.name = 'observation.in dex';
i.value = 'number';
document.getEle mentById('dropD ownList').appen dChild(i);
// add hidden comment
var i = document.create Element('input' );
i.type = 'hidden';
i.name = 'observation.nu mber.comment';
i.id = 'observation.nu mber.comment';
document.getEle mentById('dropD ownList').appen dChild(i);
// add hidden breeding code
var i = document.create Element('input' );
i.type = 'hidden';
i.name = 'observation.nu mber.breedingCo de';
i.id = 'observation.nu mber.breedingCo de';
document.getEle mentById('dropD ownList').appen dChild(i);
// add species name
document.getEle mentById('dropD ownList').appen dChild(td);
var txt = document.create TextNode(specie s);
document.getEle mentById('dropD ownList').appen dChild(txt);
// add checkbox
document.getEle mentById('dropD ownList').appen dChild(td);
var i = document.create Element('input' );
i.type = 'checkbox';
i.name = 'observation.nu mber.species';
var d = document.getEle mentById( 'dropDownList' );
d.appendChild( i );
// add textbox
document.getEle mentById('dropD ownList').appen dChild(td);
var i = document.create Element('input' );
i.type = 'text';
i.name = 'observation.nu mber.speciesCod e';
i.size = '7';
i.maxlength = '7';
var d = document.getEle mentById( 'dropDownList' );
d.appendChild( i );
}
</script>[/CODE]
Comment