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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T05:03:05+00:00 2026-06-08T05:03:05+00:00

I tried writting a function which receives an input from the user as to

  • 0

I tried writting a function which receives an input from the user as to how many field to create in a form. Then the function creates a Form which contains number(equivalent to user input) of textboxes and one submit button. I wrote the function but it doesnt seem to be working where have i gone wrong. I would be grateful if any one can help me.
My code:

function createTextBox()
    {   
        var box=document.getElementById('pop');                             //getting the ID of the containner
        var val=document.getElementById('uValue').value;                    //getting the Input value from the user

        var candidateForm=document.createElement('form');                   //Creating a form and giving the attributes
        candidateForm.name="candidateForm";
        candidateForm.method="post";
        candidateFomr.action="process.php";

        for(var i=0; i<val;i++)
        {
            var newTextbox = document.createElement('input');               //creating the textboxes according to the users input
            newTextbox.type="textbox";
            newTextbox.name="candidate[]";
            newTextbox.id="candidateId";

            candidateForm.appendChild(newTextbox);                          //putting the created textboxes in the form

        }

        var saveButton=document.createElement('input');                     //creating the submit button which when clicked will save the value written in the textboxes
        saveButton.type="submit";
        saveButton.name="submitButton";
        saveButton.value="Enter";
        candidateForm.appendChild(saveButton);                              //putting the submit button in the form

        box.appendChild(candiateForm);                                      //And putting the form in the containner.

        //alert (val);
    }

here is the HTML part

<body>
<input type="textbox" name="value_box" id="uValue" ></input>
<input type="button" onclick="javascript:createTextBox()" value="Click"></input>
<div id="pop"></div>
</body>

Thanks in Advance 😀

  • 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-08T05:03:07+00:00Added an answer on June 8, 2026 at 5:03 am

    To begin with input types are standalone tag.

    Change your HTML to

    <input type="textbox" name="value_box" id="uValue" />
    <input type="button" onclick="javascript:createTextBox()" value="Click"/>
    <div id="pop"></div>
    

    Also made changes to the js

    function createTextBox()
        {   
            var box=document.getElementById('pop');                             //getting the ID of the containner
            var val=document.getElementById('uValue').value;                    //getting the Input value from the user
    
            var candidateForm=document.createElement('form');                   //Creating a form and giving the attributes
            candidateForm.name="candidateForm";
            candidateForm.method="post";
            candidateFomr.action="process.php";
    
            for(var i=0; i<val;i++)
            {
                var newTextbox = document.createElement('input');               //creating the textboxes according to the users input
                newTextbox.type="textbox";
                newTextbox.name="candidate[]";
                newTextbox.id="candidateId";
    
                candidateForm.appendChild(newTextbox);                          //putting the created textboxes in the form
    
            }
    
            var saveButton=document.createElement('input');                     //creating the submit button which when clicked will save the value written in the textboxes
            saveButton.type="submit";
            saveButton.name="submitButton";
            saveButton.value="Enter";
            candidateForm.appendChild(saveButton);                              //putting the submit button in the form
    
            box.appendChild(candiateForm);                                      //And putting the form in the containner.
    
            //alert (val);
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am writing a function which would get all files from a particular directory
This works Toying with C++11, I tried to build a function which concatenates arbitrary
I'm trying to learn Lisp (elisp, actually), and I tried writing the following function
I am writting my custom helper. I tried to use the language helper: $this->lang->line('site_title')
So I have tried to do this extensively but to no avail.. I'm writting
I am writing a script which counts all files and folders recursively. I tried
I tried writing a generic, in place, intersperse function. The function should intersperse a
I have a form with many fields and 2 submit buttons. I want to
After completing an assignment to create Pascal's triangle using an iterative function, I have
I've been writing a javascript function which returns true if the value matches one

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.