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 6165341
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T22:08:49+00:00 2026-05-23T22:08:49+00:00

Im trying to make a script to add an input field when a current

  • 0

Im trying to make a script to add an input field when a current one is clicked using ajax/appendChild but it is not working. Here is my script..

<script type="text/javascript">
function addfile()
{
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
 var s = xmlhttp.responseText;
var div = createElement('div');
div.innerHTML = s;
document.getElementById("org_div1").appendChild = div;
    }
  }
xmlhttp.open("GET","addfile.php");
xmlhttp.send();
}
</script>

And html..

<div id="org_div1" class="file_wrapper_input">

                        <input type="hidden" value="1" id="theValue" />
<input type="file" class="fileupload" name="file1" size=
"80" onchange="addfile()" /></div>

And addfile.php file..

<script type="text/javascript">
    var i=0;
        var ni = document.getElementById('org_div1');
        var numi = document.getElementById('theValue');
    var i=0;
        var ni = document.getElementById('org_div1');
        var numi = document.getElementById('theValue');
        var num = (document.getElementById('theValue').value -1)+ 2;
        numi.value = num;
        var divIdName = num;
</script>
<input type="file"  class="fileupload" size="80" name="file' + (num) + '" onchange="addfile()" />;

Any input? Thanks.

  • 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-23T22:08:50+00:00Added an answer on May 23, 2026 at 10:08 pm

    It should be:

    document.getElementById("org_div1").appendChild(div);
    

    and

    var div = document.createElement('div');
    

    See:

    • https://developer.mozilla.org/En/AppendChild
    • https://developer.mozilla.org/en/document.createElement

    From above reference (syntax):

     var child = element.appendChild(child);
    
     var element = document.createElement(tagName);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to make a PHP script, I have the script finished but it
I have been trying to make an init script using start-stop-daemon. I am stuck
I'm totally new to GreaseMonkey, but I'm trying to make a little script. //
I am trying to make a Postgres PHP backup script. I have downloaded one
I'm trying to make some ajax-functionality in my web application, but I cannot get
I'm trying to make a script to start a second counter. [but later I
I'm trying to add and remove divs using checkboxes. Some help for this script
I've got autocomplete working fine, but I'm trying to figure out way to make
I'm trying to make a script so that I can easily add host types
I'm trying to make a script that automatically starts uploading after the data has

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.