使用jquery将表单输入数据从一个字段集显示到另一个字段集

时间:2015-02-25 18:57:54

标签: javascript jquery html5 forms

我正在尝试将所有表单输入值从字段集显示到下一个字段集以供审阅,然后使用提交按钮提交。

我在Google上搜索了解决方案,发现可以使用jquery serialize实现。但我希望它显示为一个表单但显示禁用字段。

请引导我走向正确的方向。

这是我的代码。

//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://fonts.googleapis.com/css?family=Montserrat);

/*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="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script src="http://thecodeplayer.com/uploads/js/jquery.easing.min.js"></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>

0 个答案:

没有答案