Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3807376
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T14:58:53+00:00 2026-05-19T14:58:53+00:00

how can i remove dynamically created elements from form by using click function on

  • 0

how can i remove dynamically created elements from form by using click function on image?
the code is:

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">

<HEAD>
<TITLE>Attendee's List</TITLE>
<script type="text/javascript"src="js/atendee_jquery.js"></script>
<script type="text/javascript" src="js/jquery-1.4.4.min.js" /> </script>
<script type="text/javascript" src="js/jquery-ui-1.8.9.custom.min.js"></script>
<script src="http://jquery-ui.googlecode.com/svn/tags/latest/external/jquery.bgiframe-2.1.2.js" type="text/javascript"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.8/i18n/jquery-ui-i18n.min.js" type="text/javascript"></script>
<script src="http://code.jquery.com/jquery-1.4.4.js"></script>
<link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.7/themes/base/jquery-ui.css" type="text/css" media="all" />
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js" type="text/javascript"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.7/jquery-ui.min.js" type="text/javascript"></script>

<!--<div id="draggable" class="ui-widget-content">-->
<script type="text/javascript" />
var ii=0;
function add(type) {

    //Create an input type dynamically.
    var element = document.createElement("input");
    var element2=document.createElement("input");
    var element3=document.createElement("img");
    var e="img"+type;
    element3.setAttribute("type","img");
    element3.setAttribute("value",type);
    element3.setAttribute("src","C:/Documents%20and%20Settings/Gayakwad/Desktop/MpPro/WebContent/img/delete.png");
    element3.setAttribute("name", e);

    element2.setAttribute("type", "text");
    element2.setAttribute("value", type);
    ii=ii+1;
    var o=type+ii;
    element2.setAttribute("name", o);

    //Assign different attributes to the element.
    element.setAttribute("type", "checkbox");
    element.setAttribute("value", type);
    var d="chk"+type;
    element.setAttribute("name",d);
    // element3.addEventListener("onclick",element2.removeAttribute("text1"),false);
    var foo = document.getElementById("draggable1");

    //Append the element in page (in span).

    foo.appendChild(element2);
     foo.appendChild(element);
     foo.appendChild(element3);
 remove_option(menu);

    var mybr = document.createElement("br");
foo.appendChild(mybr);
var mybr2 = document.createElement("br");
foo.appendChild(mybr2);


}
</script>


<script type="text/javascript">
</script>
<!--</div>-->
<script language="javascript">
function remove_option(selectbox)
{
var i;
var sel=selectbox.selectedIndex;
selectbox.remove(sel);
}
</script>
<style>
    #draggable1 { width: 150px;  padding: 0.5em; }
    #draggable1 h3 { text-align: center; margin: 0; }
    </style>

<script>
    $(function() {
        $( "#draggable1" ).draggable();
        $( "#draggable1" ).resizable({
                handles: "n, e, s, w"
      });
    });

</script>

<script type="text/javascript">
function ShowHide(divId)
{
var ele=document.getElementById(divId);
ele.remove(divId);
}
</script>

</HEAD>

<BODY>
<div id="attendee_list">
<FORM>
<H2>Select the fields you want from list and press add.</H2>
<BR/>
<h4>Select the fields that are visible public</h4>

<SELECT name="element" id="menu">
    <OPTION value="Name">Name</OPTION>
    <OPTION value="Age">Age</OPTION>
    <OPTION value="Date of birth">Date of birth</OPTION>
    <OPTION value="Designation">Designation</OPTION>
    <OPTION value="E-mail ID">E-mail ID</OPTION>
    <OPTION value="Contact Number">Contact Number</OPTION>
    <OPTION value="Place">Place</OPTION>
    <OPTION value="Company Name">Company Name</OPTION>
    <OPTION value="Address">Address</OPTION>
    <OPTION value="Number of guests">Number of guests</OPTION>
    <OPTION value="Comments">Comments</OPTION>
</SELECT>

<INPUT type="button" value="Add" onClick="add(document.forms[0].element.value)" style="position:fixed; top:146px; left:150px"/> 
 <input type="submit" value="Submit" style="position:fixed; top:146px; left:200px" /> 
 <input type="button" value="Delete element" style="position:fixed; top:146px; left:270px" onClick="ShowHide('text0')"/> 
<span id="fooBar"> <br/>&nbsp; &nbsp; &nbsp;<br/></span>

<!--<span id="fooBar1"> &nbsp; &nbsp; &nbsp;</span>-->

</div>
<br/>
<div id="draggable1" style="border:solid; min-width:200px; min-height:300px; position:relative; bottom:20px; display:block"></div>

</FORM>

</BODY>
</html>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T14:58:54+00:00Added an answer on May 19, 2026 at 2:58 pm

    first select your container of object in your case is draggable1, then select the children from container and remove based on index

    $("#draggable1").children().remove();
    

    -> but this will remove all children

    or you can optionally filter the children like

    $("draggable1").children(":contains('sometext')").remove();

    or another filter in children object using the index of children

    $("draggable1").children(":nth-child(0)").remove();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I dynamically add and remove elements form VGroups. When I create an element and
How can i remove an ImageView added on a dynamically created UIView, so that
I am trying to remove a dynamically created element using jQuery. Here is my
The problem in my case is I can dynamically add / remove input boxes,
we can remove formula from one cell by cell.setCellFormula(null) . but if i want
One can remove all calls to printf() using #define printf . What if I
How we can remove an array entry from : var a = [],b =
How to I can remove posts from a specific category from homepages in wordpress?
Is there a way I can remove the background bar image in the SeekBar
I have a number of DOM elements being dynamically created on a web page.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.