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

  • Home
  • SEARCH
  • 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 8098935
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T22:14:21+00:00 2026-06-05T22:14:21+00:00

This is my page code: <!DOCTYPE HTML> <html> <head> <meta charset="UTF-8"> <title>Marketing Tracking</title> </head>

  • 0

This is my page code:

<!DOCTYPE HTML>
<html>
    <head>
        <meta charset="UTF-8">
        <title>Marketing Tracking</title>
    </head>
    <body>
        <form action="#" id="form" method="post">
            <div id="namevalues">
                <span id="span:1">
                    <input type="text" id="name:1" onchange="changed(this)" style="width:300px;"/>
                    <input id="value:1" type="number" min="0" value="0" /><br /></span>
            </div>
            <input type="button" id="add" value="Add 1" />
            <br />
            <textarea name="talk" style="width:500px;height:175px;"></textarea>
            <br />
            <input type="button" id="update" value="Update"/>
        </form>
        <script>
function get(a){return document.getElementById(a);}
    up=get("update");
    up.onclick = function(){
    get("form").submit();
}
get("name:1").onchange = function(){changed(this)};
get("add").onclick = function(){add()};<% z=2 %>
function changed(ele){
    id=ele.id;
    val=ele.value;
    id=id.split(":")[1];
    get("value:"+id).name=get("name:"+id).value;
}
function add(){
    document.getElementById("namevalues").innerHTML+='<span id="span:'+z+'"><input type="text" id="name:'+z+'" onchange="changed(this)" style="width:300px;"/><input id="value:'+z+'" type="number" min="0" value="0" /><br /></span>';
}
        </script>
    </body>
</html>

I am very confused as to why when I press the Add 1 button enter some text and then press the Add 1 button again the text that I just entered disappears!

If anyone could give some insight to this it would be greatly appreciated.

  • 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-06-05T22:14:22+00:00Added an answer on June 5, 2026 at 10:14 pm

    The reason your other values disappear is because when you do something.innerHTML += something it will rewrite the HTML for that zone (meaning what was there before is gone and will be replaced with fresh new HTML). What you probably want to do is something along this :

    function add(){
        var div = document.createElement("div");
        div.innerHTML = '<span id="span [... the rest of the code ...]<br /></span>';
        document.getElementById("namevalues").appendChild(div);
    }
    

    Using appendChild won’t alter the other element that are already in the div namevalues.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My webpage code is this: <!DOCTYPE html> <html> <head> <meta charset=utf-8 /> <title>index</title> </head>
I have this html and css code: <!DOCTYPE html> <html lang=en> <head> <meta charset=utf-8
Here is my code: <!DOCTYPE html> <html> <head> <meta charset=utf-8> <meta name=viewport content=width=device-width, initial-scale=1>
In the master page I have the following code: <!DOCTYPE html> <html> <head> <meta
Here is my code: <%@ page language=java pageEncoding=UTF-8 contentType=text/html; charset=utf-8%> <% // some code
Using the code from this page to start with: http://www.java2s.com/Code/CSharp/GUI-Windows-Form/DragginganddroppingbetweenListView.htm I am trying to
The code comes from this page: http://pubs.opengroup.org/onlinepubs/009695399/functions/dlsym.html Can you help me understand this? It
I have the following Javascript code add_num = { f: function(html, num) { alert(this.page);
Im using HTML5 offline storage My Index.html page <!DOCTYPE html> <html lang=en manifest=/offline-cache.manifest> <head>
This is the source of my simple HTML page (save as .html file): <!DOCTYPE

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.