Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem creating labels to dynamically generated output

Status
Not open for further replies.

SenTnel

Technical User
Dec 9, 2003
45
DO
Hello!

Im having problem generating the labels for content created by the following function:

Code:
function setOutput(){
    if(httpObject.readyState == 4){
		var answer = httpObject.resultsponseText.split(",");
		var results = document.getElementById("resultsultadosScan1");
		var article = document.createElement("div");
		var weight = document.createElement("div");
		var price = document.createElement("div");
		article.className = "article";
		weight.className = "weight";
		price.className = "price";
        document.getElementById('outputText0').value = httpObject.innerHTML= answer[0];
		document.getElementById('outputText1').value = httpObject.innerHTML= answer[1];
		document.getElementById('outputText2').value = httpObject.innerHTML= answer[2];
		article.innerHTML = httpObject.innerHTML= answer[0];
		weight.innerHTML = httpObject.innerHTML= answer[1];
		price.innerHTML = httpObject.innerHTML= answer[2];
		results.appendChild(article);
		results.appendChild(weight);
		results.appendChild(price);
    }
 
}

A friend showed me this sample script to achieve generation of labels on my script, but I have been trying for hours with no luck, can someone take a look and tell me the correct usage of this script:


Code:
function crearLabel() {
    var target = document.getElementById("target");
    var label = document.createElement("label"); 
    var text = document.createTextNode("Article"); 
    label.appendChild(text);
    target.appendChild(label); 
}




Thanks a lot!
 
The crearLabel function you've given assumes that there is an element present with an ID attribute of "target". I don't see any reference to this anywhere, so unless you've got one stashed away on a page that you're not mentioning, it's not likely to work.

Perhaps "target" was meant to be a parameter to the crearLabel function instead of a literal string?

Dan



Coedit Limited - Delivering standards compliant, accessible web solutions

Dan's Page [blue]@[/blue] Code Couch:
Code Couch Snippets & Info:
The Out Atheism Campaign
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top