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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T06:10:13+00:00 2026-05-28T06:10:13+00:00

I´ve read a lot of post about jQuery serialize() but I cant get it

  • 0

I´ve read a lot of post about jQuery serialize() but I cant get it to work with my form!

I works when I print out the form using html+php but not when I use javascript to print out the form. What am I missing?

I know there is a bunch of post about this but every one I´ve found is about ppl forgetting name=”” or disabled the ( Try my code here: http://jsfiddle.net/ZBxkz/1/ )

<!DOCTYPE html>

<head>
    <link rel="stylesheet" type="text/css" href="style.css">
    <title>MerBeer</title>

    <!-- //jquery -->
    <script type="text/javascript" src="../js/jquery-1.7.1.min.js"></script>
    <!-- //Ajaxscript: -->

    <script type="text/javascript">
        $(document).ready(function () {

         $("#knappen")    
        .delegate('button[name="minKnapp"]', "click", beer_insert);

        $("#theForm")    
        .delegate('button[name="beer_form_submit"]', "click", serial);

        function serial(){

            var f = $('#beer_form'); // CHANGE THIS VALUE TO CHANGE FORM!! #beer_form and #testForm
            var beerContainer = f.serialize();
            alert (beerContainer);

        }

        function beer_insert() {

                //hide first button
                $('#dold').hide();

               //Dynamically added form
                $('#theForm').html('Test :<br><form name="beer_form" id="beer_form"><table id="beers">');
                for (var i = 0; i < 1; i++){
                    $('#theForm').append('<tr><td><input type="text" name="beerCountry" id="beerNo_'+i+'_country" /></td></tr>');
                }
                $('#theForm').append('</table></form><br>');

                $('#theForm').append('<button name="beer_form_submit">Second button</button><br>')
        }
    });

    </script> 

    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>

<body>
    <!-- Form that works-->
    <form id="testForm" name="testForm">
        <table>
            <?php
                for($i = 0; $i < 3; $i++){
                    echo('<tr><td><input type="text" name="test" id="inget'.$i.'"/></td></tr>');
                }
            ?>
            <tr><td><input type="text" name="test" id="ingetA"/></td></tr>
            <tr><td><input type="text" name="test" id="ingetB"/></td></tr>
        </table>
    </form>        

    <div id="theForm"></div>
    <div id="knappen"><button id="dold" name="minKnapp">The Button</button></div>

</body>

  • 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-28T06:10:14+00:00Added an answer on May 28, 2026 at 6:10 am

    I hope I got your question right, but probably you want this?: http://jsfiddle.net/jyM5Z/

    Don’t put your html together with many appends. Instead first build a complete html string and then add it to your container. This will not only make it much faster but will also protect you from unexpected behaviour because the browser parses your HTML fragment and changes it in order to make sense (like automatically close open tags).

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

Sidebar

Related Questions

I read a lot about changing the metadata of music or images, but what
I've read a lot of answers about it, but sometimes they were arrays and
I got question about log4net is it working on IIS 7,5? I read lot
I read a lot, also here, but couldn't find a simple way to do
I read a lot about handling 2D arrays in CUDA and i think it
I have been reading over a lot of questions, but cant seem to find
Recently, I read a post on Stack Overflow about finding integers that are perfect
I know there are a lot of questions out there about this - believe
I've read a lot of post (maybe not enough) in which users say to
I've read a lot of things about authentication in CouchDB, especially regarding the Cookie

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.