mercredi 25 février 2015

Display form input data from one fieldset to another fieldset using jquery

I am trying to display all the form input values from a fieldset to next fieldset for reviewing and then submit using submit button.


I have searched for solution on Google and found that it can be achieved using jquery serialize. But I want it to display as a form but with disabled fields.


Please guide me to the right direction.


This is my code.





//jQuery time
var current_fs, newdc, adc, next_fs, previous_fs; //fieldsets
var left, opacity, scale; //fieldset properties which we will animate
var animating; //flag to prevent quick multi-click glitches



//Review New Domain Controller
$(".review").click(function(){
if(animating) return false;
animating = true;

current_fs = $(this).parent();
next_fs = $('.newdcreview');

//show the next fieldset
$('.newdcreview').show();
//hide the current fieldset with style
$('.newdc').animate({opacity: 0}, {
step: function(now, mx) {
//as the opacity of current_fs reduces to 0 - stored in "now"
//1. scale current_fs down to 80%
scale = 1 - (1 - now) * 0.2;
//2. bring next_fs from the right(50%)
left = (now * 50)+"%";
//3. increase opacity of next_fs to 1 as it moves in
opacity = 1 - now;
current_fs.css({'transform': 'scale('+scale+')'});
$('.newdcreview').css({'left': left, 'opacity': opacity});
},
duration: 800,
complete: function(){
current_fs.hide();
animating = false;
},
//this comes from the custom easing plugin
easing: 'easeInOutBack'
});
});




$(".submit").click(function(){
return false;
});



/*custom font*/
@import url(http://ift.tt/1etXiq2);

/*basic reset*/
* {margin: 0; padding: 0;}

html {
height: 100%;


}

body {
font-family: montserrat, arial, verdana;
}
/*form styles*/
#msform {
width: 400px;
margin: 50px auto;
text-align: center;
position: relative;
}
#msform fieldset {
background: white;
border: 0 none;
border-radius: 3px;
box-shadow: 0 0 15px 1px rgba(0, 0, 0, 0.4);
padding: 20px 30px;

box-sizing: border-box;
width: 80%;
margin: 0 10% 50px;

/*stacking fieldsets above each other*/
position: absolute;
}
/*Hide all except first fieldset*/
#msform fieldset:not(:first-of-type) {
display: none;
}
/*inputs*/
#msform input, #msform textarea {
padding: 15px;
border: 1px solid #ccc;
border-radius: 3px;
margin-bottom: 10px;
width: 100%;
box-sizing: border-box;
font-family: montserrat;
color: #2C3E50;
font-size: 13px;
}
/*buttons*/
#msform .action-button {
width: 100px;
background: #27AE60;
font-weight: bold;
color: white;
border: 0 none;
border-radius: 1px;
cursor: pointer;
padding: 10px 5px;
margin: 10px 5px;
}
#msform .action-button:hover, #msform .action-button:focus {
box-shadow: 0 0 0 2px white, 0 0 0 3px #27AE60;
}

.main {
margin-top:20px;
margin-bottom:20px;
}

#msform .main .action-button {
width: 250px;
background: #27AE60;
font-weight: bold;
color: white;
border: 0 none;
border-radius: 1px;
cursor: pointer;
padding: 10px 5px;
margin: 10px 5px;
}
/*headings*/
.fs-title {
font-size: 15px;
text-transform: uppercase;
color: #2C3E50;
margin-bottom: 10px;
}
.fs-subtitle {
font-weight: normal;
font-size: 13px;
color: #666;
margin-bottom: 20px;
}



<script src="http://ift.tt/Zv5K7g"></script>
<script src="http://ift.tt/1nCZ96O"></script>
<form id="msform">


<fieldset class="newdc">
<h2 class="fs-title">New Domain Controller</h2>
<h3 class="fs-subtitle">Fill all the fields below</h3>
<input type="text" name="ip" id="ip" placeholder="IP" />
<input type="text" name="subnet" id="subnet" placeholder="Subnet Mask" />
<input type="text" name="gateway" id="gateway" placeholder="Gateway" />
<input type="text" name="hostname" id="hostname" placeholder="Hostname" />
<input type="text" name="domain" id="domain" placeholder="Domain Admin Name" />
<input type="text" name="netbios" id="netbios" placeholder="NetBios Name" />
<input type="text" name="password" id="password" placeholder="Password" />
<input type="text" name="confirm_password" id="confirm_password" placeholder="Re-enter Password" />
<input type="button" name="next" class="review action-button" value="Submit" />
</fieldset>
<fieldset class="newdcreview">
<h2 class="fs-title">New Domain Controller</h2>
<h3 class="fs-subtitle">Fill all the fields below</h3>
<input type="text" class="show_ip" readonly="readonly" />
<input type="text" class="show_subnet" readonly="readonly" />
<input type="text" class="show_gateway" readonly="readonly" />
<input type="text" class="show_hostname" readonly="readonly" />
<input type="text" class="show_domain" readonly="readonly" />
<input type="text" class="show_netbios" readonly="readonly" />
<input type="text" class="show_password" readonly="readonly" />
<input type="button" name="next" class="next action-button" value="Confirm" />
</fieldset>

</form>



Aucun commentaire:

Enregistrer un commentaire