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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T01:10:49+00:00 2026-05-24T01:10:49+00:00

If I have a form element as given below, then calling the form’s submit

  • 0

If I have a form element as given below, then calling the form’s submit will automatically generate the request body/query parameters in the url-encoded form as “username={username}&password={password}&submit=submit” where values in {} are taken from the corresponding input element’s text boxes.

<form action="/action.php" method="POST">
  <input id="username"  type="text" />
<input id="password"  type="password" />
<input type="submit"  id="submit" value="submit" />
</form>

But if I am going to place my input elements in multiple levels of div’s, then the form submit will fail to generate the request body/query parameters.

<form action="/action.php" method="POST">
   <div id="inside_formdiv">
      <div id="userdiv">
        <input id="username"  type="text" />
      </div>
      <div id="passworddiv">
        <input id="password"  type="password" />
      </div>
      <div id="submit_div">
         <input type="submit"  id="submit" value="submit" />
      </div>
   </div>
</form>

Can anyone tell me the reason why it is like that? The specification doesn’t mention that the input elements should be immediate children of Form element. I was wondering a proper reason for this behavior.

The values will be populated to the elements and you can check the values also if you edit the changes as given below

<script type="text/javascript">
  function logincheck() {
    alert ('hi ' + document.getElementById('username').value);
    alert ('hi ' + document.getElementById('password').value);
   }
 </script>


 <form action="/action.php" method="POST">
   <div id="inside_formdiv">
      <div id="userdiv">
        <input id="username"  type="text" />
      </div>
      <div id="passworddiv">
        <input id="password"  type="password" />
      </div>
      <div id="submit_div">
         <input type="submit"  onclick="logincheck()" />
      </div>
   </div>
</form>
  • 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-24T01:10:50+00:00Added an answer on May 24, 2026 at 1:10 am

    The first thing I notice is that your inputs are missing the “name” attribute. It’s not required by the HTML spec afaik, but I think this is why the values are not sent with the request.

    <form action="/action.php" method="POST">
          <div id="inside_formdiv">
             <div id="userdiv">
                <input id="username" name="username" type="text" />
             </div>
             <div id="passworddiv">
                <input id="password" name="password" type="password" />
             </div>
             <div id="submit_div">
                <input type="submit" onclick="logincheck()" />
             </div>
          </div>
       </form>
    

    This should do the trick

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

Sidebar

Related Questions

I have a form where the admins will be uploading more then 2 pictures
I have the HTML code given below. When I try to submit the inner
I have a form element that contains multiple lines of inputs. Think of each
I have a form element that I want to address via javascript, but it
I have some AJAX work that brings across an additional form element that I
I have an XML form with an element 0, which is well-formed but not
Given an HTML form element like: <select id='mydropdown'> <option value='foo'>Spam</option> <option value='bar'>Eggs</option> </select> I
I have Ajax login form, which is checking whether given credentials are correct and
I have quite a large IF statement which needs to update another form element
hi i am using zend form , i created a Zend_Form_Element_Radio element that have

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.