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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T08:54:50+00:00 2026-05-12T08:54:50+00:00

Given the following form: <form id=form name=form> <input name=name/> <input name=version/> <input name=template/> <textarea

  • 0

Given the following form:

<form id="form" name="form">
<input name="name"/>
<input name="version"/>
<input name="template"/>
<textarea name="elements"></textarea>
<textarea name="features"></textarea>
<textarea name="layout"></textarea>
<input type="submit" value="Save"/>
</form>

and javascript (using jQuery 1.3.2):

$(function() {
    $('#form').bind('submit',function() { alert($('#form').serialize()); return false; });
    });

The output of submitting the above form from the above javascript alert is:

elements=...

Where … is whatever is contained in the elements field.

I would expect that $(‘#form’).serialize() to return a string something like:

name=&version=&template=&elements=&features=&layout=.

I do note that $(‘input,textarea’).serialize() does perform the expected behaviour (i.e. return “name=&version=&template=&elements=asdafe&features=&layout=”), however I’m curious as to why the $(‘#form’) version only returns “elements=”.

I’ve tried this on Safari 4 and Firefox 3.5, so I’m confident it’s something I’m missing.

Thanks for reading.

  • 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-12T08:54:50+00:00Added an answer on May 12, 2026 at 8:54 am

    It’s the name of your textarea that’s throwing it off.

    Here’s how it breaks down. In the DOM, form nodes have several special properties, most notably these two (which are exposed in this order)

    1. The elements collections, which is an HTMLCollection of all the form controls (and a few other nodes like <fieldset> elements)
    2. A property of each named element in the form (i.e., form controls that have a name attribute)

    Since you have a <textarea> with the name “elements”, this effectively overwrites the built-in elements collection mentioned in #1 above, which is why when you serialize the form all you see is

    elements=****
    

    Because that single form element has overwritten the entire collection.

    Short solution? re-name your form elements to values that aren’t existing DOM properties (your <input name="name"/> falls into this category as well)

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

Sidebar

Ask A Question

Stats

  • Questions 199k
  • Answers 199k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer There does not appear to be any way to get… May 12, 2026 at 7:41 pm
  • Editorial Team
    Editorial Team added an answer As David says, structs are public by default, classes are… May 12, 2026 at 7:41 pm
  • Editorial Team
    Editorial Team added an answer Here's an alternate way of setting up your application: If… May 12, 2026 at 7:41 pm

Related Questions

Given the following classes and controller action method: public School { public Int32 ID
I have a list of URLs in my homepage which is like SO in
Given the following HTML fragment: <form id=aspnetForm onsubmit=alert('On Submit Run!'); return true;> I need
I have a form in an ASP.NET MVC project which has a select drop

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.