form clone
by skydivematy
HTML
<script src="https://code.jquery.com/jquery-2.2.0.min.js"></script>
<script src="https://padi.calypsodivecenter.com/Resources/Public/Packages/Sites/calypso_style/Template/JavaScript/jquery-calx-2.2.7.min.js?1456408403"></script>
<div class="Tx-Formhandler">
<form method="post" action="/courses/padi/padi-divemaster-gopro-and-stay-closely-with-a-padi-instructor/" class="cd-form ym-form ym-full linearize-form floating-labels reservations_form" id="reservationsForm" data-calx-identifier="CALX1456940974335" data-format="€0,0.00">
<input type="hidden" name="id" value="23">
<input type="hidden" name="reservations[submitted]" value="1">
<input type="hidden" name="reservations[randomID]" value="be7ca88e30df4ecef6f2a0896f1ea0b6">
<input type="hidden" id="removeFile-be7ca88e30df4ecef6f2a0896f1ea0b6" name="reservations[removeFile]" value="">
<input type="hidden" id="removeFileField-be7ca88e30df4ecef6f2a0896f1ea0b6" name="reservations[removeFileField]" value="">
<input type="hidden" id="submitField-be7ca88e30df4ecef6f2a0896f1ea0b6" name="reservations[submitField]" value="">
<input type="hidden" name="reservations[step-2-next]" id="ieHiddenField-be7ca88e30df4ecef6f2a0896f1ea0b6" value="1">
<input type="hidden" size="20" id="TEXT" name="reservations[hidden]" value="1">
<!-- begin #entry1 -->
<div id="entry1" class="clonedInput">
<div class="ym-gr ym-gbox-right-bb">
<div class="ym-fbox-wrap ym-grid">
<div class="ym-g50 ym-gl ym-gbox-left-bb">
<div class="ym-fbox-text ym-grid">
<h2 id="participantHeader" class="participantHeader">
Course participant
<span id="reference" name="reference" class="heading-reference">#1</span>
</h2>
</div>
</div>
<div class="ym-g50 ym-gr ym-gbox-right-bb">
...
JavaScript
/*
Author: Tristan Denyer (based on Charlie Griefer's original clone code, and some great help from Dan - see his comments in blog post)
Plugin repo: https://github.com/tristandenyer/Clone-section-of-form-using-jQuery
Demo at http://tristandenyer.com/using-jquery-to-duplicate-a-section-of-a-form-maintaining-accessibility/
Ver: 0.9.4.1
Last updated: Sep 24, 2014
The MIT License (MIT)
Copyright (c) 2011 Tristan Denyer
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
//$('calx2, reservationsForm').calx();
sheet = $('#reservationsForm').calx();
$(function () {
var id = 1;
var entry1 = $('#entry1');
entry1.on('change', 'select#insuranceTypeSelect', function (e) {
// var val = $(e.target).val();
var value = $(e.target).find("option:selected").val();
$('#B1').val(this.value);
console.log(this.value);
// $('#reservationsForm').calx();
sheet.calx();
//alert(this.value); // or $(this).val()
return false;
...