Add label to table cell

Posted on 2010-01-02
Last Modified: 2013-11-18
I have an HTML table.
The below code is attempting to add a <p> tag to act as a label to show the results of the ajax call.   My attempt is to do the following steps:
1.  identify the parent of the current field, which should be the <td>.
2. Add a <p> to the <td> as a child
3. Populate the <p>

How can I add the label.  I need to keep it dynamic.

here is the err:
Webpage error details

User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0; Trident/4.0; SLCC1; .NET CLR 2.0.50727; InfoPath.1; .NET CLR 3.5.30729; .NET CLR 3.0.30729; .NET CLR 1.1.4322)
Timestamp: Sat, 2 Jan 2010 15:20:49 UTC

Message: Type mismatch.

Line: 1063
Char: 3
Code: 0
URI: http://7iprod/ifas7/workflow/custom/SUTTERPPF/common/wfcommon.js

if(id.indexOf("glkey") > -1)



	var glkey = document.getElementById(id).value


	       xmlhttpPost("SUTTERPPF/common/wfbdrvgljukeyobj.asp", "mode=getglkey&glkey=" + glkey)

		var parent = document.getElementById(id).parentNode

		label = parent.appendChild("p") 

		label.innerHTML = responseVal


Open in new window

Question by:KeithMcElroy
    LVL 81

    Expert Comment

    Hello KeithMcElroy,

    What's line 1063 in the code snipet ?

    LVL 22

    Accepted Solution

    here s the revised code.

    if(id.indexOf("glkey") > -1)
    	var glkey = document.getElementById(id).value;
    	xmlhttpPost("SUTTERPPF/common/wfbdrvgljukeyobj.asp", "mode=getglkey&glkey=" + glkey);
    	var parent = document.getElementById(id).parentNode;
    	var label = document.createElement("p");
    	label.innerHTML = responseVal;

    Open in new window


    Author Closing Comment


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Javascript: Crash Course

    Javascript is not only emerging as the most important language to know, it's flexibility is unique. With Javascript being deployed on the web, mobile and even the desktop this is the one language that all technologists need to know.

    This article shows how to create and access 2-dimensional arrays in JavaScript.  It includes a tutorial in case you are just trying to "get your head wrapped around" the concept and we'll also look at some useful tips for more advanced programmers. …
    Avoid defining the variables in the global scope; trying to define them in a local function scope. Because:   • Look-up is performed every time a variable is accessed.   • Variables are resolved backwards from most specific to least specific scope…
    The purpose of this video is to demonstrate how to set up the WordPress backend so that each page automatically generates a Mailchimp signup form in the sidebar. This will be demonstrated using a Windows 8 PC. Tools Used are Photoshop, Awesome…
    The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    11 Experts available now in Live!

    Get 1:1 Help Now