dynamically created object in javascript

Posted on 2016-08-18
Last Modified: 2016-09-02
how to add dynamically labels to a panel that contains a textbox but i need the label to be displayed before teh textbox
Question by:pamela rizk
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
LVL 58

Expert Comment

by:Julian Hansen
ID: 41760682
Can you provide more information.

What do you mean by dynamic - what triggers the placement of the labels - what sort of labels are we talking about - can you describe in more detail?

Author Comment

by:pamela rizk
ID: 41760686
dear mr juian
it works using floar left

Expert Comment

by:Kyaw Wanna
ID: 41760768
Please try the codes as per below :

<script src="" type="text/javascript"></script>

<style type="text/css">



<script type="text/javascript">


    var counter = 1;

    $("#addButton").click(function () { 

	var newTextBoxDiv = $(document.createElement('div'))
	     .attr("id", 'TextBoxDiv' + counter);

	newTextBoxDiv.after().html('<label>Textbox #'+ counter + ' : </label>' +
	      '<input type="text" name="textbox' + counter +
	      '" id="textbox' + counter + '" value="" >');



     $("#removeButton").click(function () {
          alert("No more textbox to remove");
          return false;


        $("#TextBoxDiv" + counter).remove();


     $("#getButtonValue").click(function () {

	var msg = '';
	for(i=1; i<counter; i++){
   	  msg += "\n Textbox #" + i + " : " + $('#textbox' + i).val();

<div id='TextBoxesGroup'> 
<input type='button' value='Add Textbox' id='addButton'>
<input type='button' value='Remove Textbox' id='removeButton'>
<input type='button' value='Get TextBox Value' id='getButtonValue'>


Open in new window

LVL 58

Accepted Solution

Julian Hansen earned 500 total points
ID: 41760792
@Pamela, I still don't have a clear indication of what you want to achieve - can you draw us a picture.

You say the lable is added dynamically - what must happen for the lable to be added
Where do you get the text for the lable
Must the lable show all the time or only when you do something

Author Closing Comment

by:pamela rizk
ID: 41781166

Featured Post

WordPress Tutorial 1: Installation & Setup

WordPress is a very popular option for running your web site and can be used to get your content online quickly for the world to see. This guide will walk you through installing the WordPress server software and the initial setup process.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

How to build a simple, quick and effective accordion menu using just 15 lines of jQuery and 2 css classes
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery including how to code hide show and toggles. 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…
Suggested Courses

617 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