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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T09:44:47+00:00 2026-05-20T09:44:47+00:00

I would like to get the updated DOM html string for the form elements

  • 0

I would like to get the updated DOM html string for the form elements (e.g. <input type="text">, <input type="radio">, <input type="radio">, <textarea>).

I found this question and I am trying to use the formhtml plugin written by gnarf:

jQuery html() in Firefox (uses .innerHTML) ignores DOM changes

The problem is that it works in Firefox and Chrome but only works partially in IE8 (I have not tested other versions).

If you open the following page in IE8, you can see there is a text box, some checkboxes and radios. Try entering some text and check the checkboxes and radios.

http://jsfiddle.net/e9j6j/1/

Then click on the ‘Click’ button.

You can see that no matter I am retrieving the html string through the innerHTML property of a native DOM object or by using the formhtml() function of the plugin. The html returned only reflects the changes in the value attribute of the textbox, you can never see the checked="checked" attributes in <input type="radio"> and <input type="checkbox"> even you have already checked them before clicking the button.

Why is this happening, and how I can make it work in IE?

Thanks in advance.

EDIT:
I am sorry. I made some mistakes in my question, now it has been rewritten.

EDIT:
The sample codes were created to demonstrate my problem but I made some mistakes. Both IE7 and IE8 do give expected results (I also did the tests again).

In my original codes, I do not directly use formhtml() function on the $('#div1') but rather clone it before using formhtml() like this:

alert($('#div1').clone().formhtml());

And on IE8 with jQuery 1.3.2, the returned html does not reflect the checked states of those checkboxes and radios, I never thought it would be the problem of the clone() function that’s why when I created the sample codes, I did not clone it and so the actual problem failed to be demonstrated.

The updated sample codes are here (with jQuery version changed to 1.3.2):

http://jsfiddle.net/e9j6j/4/

This may show the problem of the clone() function on IE8 (I don’t have IE8 right now, I will test it when I am home, I will report later).

EDIT:

I have just did the test. It’s really the problem of clone() function in jQuery 1.3.2 on IE8. It fails to copy the states of checkboxes and radios. After changing it to jQuery 1.5.1. It works perfectly.

  • 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-20T09:44:48+00:00Added an answer on May 20, 2026 at 9:44 am

    I tried the test case at http://jsfiddle.net/e9j6j/1/ on IE8 and IE7 and they worked for me.

    Steps to replicate problem:

    1. Load http://jsfiddle.net/e9j6j/1/ in IE browser.
    2. Enter text in the text field, check first radio button, check first checkbox.
    3. Press ‘Click’ button.

    Expected result:

    Both alerts show value on text field and ‘checked’ state on first radio & first checkbox.

    Actual result:

    As expected. However, bear in mind that IE’s representation of the DOM means that checked="checked" is actually reported as CHECKED but it is correct.

    UPDATED:

    Added a test to ensure that the checked state can be copied to a new dom node:

    $('#btn1').click(function() {
        alert($('#div1').formhtml());
        alert(document.getElementById('div1').innerHTML);
    
        var div1 = $('#div1');
        div1.clone().insertAfter(div1);
    });
    

    This creates another set of fields which retain the original input state.
    View on jsfiddle.

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

Sidebar

Related Questions

Would like to get a list of advantages and disadvantages of using Stored Procedures.
I would like to get data from from different webpages such as addresses of
I would like to get up-to-date information on Google's index of a website, and
I would like to get the path to the execution directory of a Windows
I would like to get the absolute position of an element in relation to
I would like to get a list of the wireless networks available. Ideally this
I would like to get all the instances of an object of a certain
I'm a lone developer who would like to get some structure to my projects.
I have taken over a large code base and would like to get an
I am running C# framework 2.0 and I would like to get some of

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.