Knowledge Walls

Ad Size: (333 X 90) px
Venkatesan
Hyderabad, Andhra Pradesh, India
Passcode:
Form values to json jquery in HTML Form of JQuery
606 Views
HTML
<form id="frm_user_form" onsubmit="return false">
  Username: <input type="text" name="txt_username" /><br />
  Password: &nbsp;<input type="password" name="txt_password" /><br />
  <button>Show Json</button>
</form>
JQuery
$(function(){
   $("button").click(function(){
        var result = {};
        $.each($("#frm_user_form").serializeArray(),function(){
             result[this.name] = this.value;
        });
        alert(JSON.stringify(result));
   });
});
Demo & Output 
Demo
http://www.knowledgewalls.com/realtimejqueryeditor/form-values-to-json-jquery

Output
{
    "txt_username":"knowledgewalls@gmail.com",
    "txt_password":"knowledgewalls"
}
Next Topics
Next lessons of current book.
Jquery Exercises of JQuery
Event handler methods of JQuery
Form Validation of JQuery
HTML Insertion of JQuery
HTML Insertion of JQuery
Previous Topics
Previous lessons of current book.
HTML Form of JQuery
Best Lessons of "JQuery"
Top lessons which are viewed more times.
Form Validation of JQuery
HTML Insertion of JQuery
Jquery Exercises of JQuery
HTML Insertion of JQuery
HTML Insertion of JQuery
HTML Insertion of JQuery
Event handler methods of JQuery
HTML Form of JQuery
  Copyright © 2014 Knowledge walls, All rights reserved
KnowledgeWalls
keep your tutorials and learnings with KnowledgeWalls. Don't lose your learnings hereafter. Save and revise it whenever required.
Click here for more details