cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

Pen Settings

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

Quick-add: + add another resource

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

Quick-add: + add another resource

Code Indentation

     

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

            
              <html>
<head lang="en">
    <meta charset="UTF-8">
    <title></title>
</head>
<body>
  <br />
    <div class="container">
        <div class="row">
            <div class=" col-md-offset-3 col-md-6">
                <div class="panel panel-primary">
                    <div class="panel-heading">
                        <h3 class="panel-title">Form User</h3>
                    </div>
                    <div class="panel-body">
                        <form id="myForm" action="#">
                          
                            <div class="form-group">
                                <label for="first_name">Nombres</label>
                                <input name="first_name" type="text" class="form-control" placeholder="Ingrese nombres" required/>
                            </div>
                          
                          
                            <div class="form-group">
                                <label for="last_name">Apellidos</label>
                                <input name="last_name" type="text" class="form-control" placeholder="Ingrese apellidos"/>
                            </div>
   
                            <div class="form-group">
                                <label for="type">Tipo</label>
                                <select name="type" class="form-control">
                                    <option value="user">Usuario</option>
                                    <option value="admin">Administrador</option>
                                </select>
                            </div>
                            <div class="form-group">
                                <label for="description">Descripción</label>
                                <textarea name="description" rows="3" class="form-control" placeholder="Acerca de mi..."></textarea>
                            </div>
                            <button class="btn btn-success">Test form to object!</button>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>
</body>
</html>
            
          
!
            
              $('#myForm').submit(function () {
  var data = formToObject(this);
  alert(JSON.stringify(data));
});

function formToObject(form) {
  var arrayForm = $(form).serializeArray();
  var objectForm = {};

  arrayForm.forEach(function (obj, index) {
    objectForm[obj.name] = obj.value;
  });
  
  return objectForm;
}
            
          
!
999px
Loading ..................

Console