Javascript 如何记住输入表单值?

Javascript 如何记住输入表单值?,javascript,forms,Javascript,Forms,我正在尝试创建两个表单,用户可以通过单击form1和formt2来选择 当用户在form1和form2之间进行选择时。我希望form2记住form1的值,并传递所选表单的值以供提交 如何以最简单的方式做到这一点 谢谢对类似的条目使用相同的输入如何 您可以使用CSS类隐藏不希望看到的元素/标签 <script type="text/javascript"> $(document).ready(function() { $('.form-select').change(funct

我正在尝试创建两个表单,用户可以通过单击form1和formt2来选择

当用户在form1和form2之间进行选择时。我希望form2记住form1的值,并传递所选表单的值以供提交

如何以最简单的方式做到这一点


谢谢

对类似的条目使用相同的输入如何

您可以使用CSS类隐藏不希望看到的元素/标签

<script type="text/javascript">
$(document).ready(function() {
    $('.form-select').change(function() {
        // changes the class of our form
        var setClass = "mode" + $('input[name=whichForm]:radio:checked').val();
        $('#theForm').attr('class',setClass);
    });
});
</script>

<style type="text/css">
    #theForm fieldset { display: inline; }       // just a visual preference
    #theForm .business { color: blue; }          // color-coding
    #theForm .personal { color: green; }         // more color-coding
    #theForm.mode1 .business { display: none; }  // hides .business items when not needed
    #theForm.mode2 .personal { display: none; }  // hides .personal items when not needed
</style>

<form id="theForm" class="mode3" action="take-form.php">
    <fieldset>
        <legend> Information </legend>
        <input type="radio" id="whichForm-1" class="form-select" name="whichForm" value="1"><label for="whichForm-1">Personal</label>
        <input type="radio" id="whichForm-2" class="form-select" name="whichForm" value="2"><label for="whichForm-2">Business</label>
        <input type="radio" id="whichForm-3" class="form-select" name="whichForm" value="3"><label for="whichForm-3">Show All (Debug)</label>
        <hr>
        <input type="text" id="name" name="name">
        <label for="name">
                <span class="personal">Your</span>
                <span class="business">Business</span>
                <span> Name</span>
        </label>
        <br>
        <input type="text" id="address" name="address">
        <label for="address">
            <span class="personal">Home</span>
            <span class="business">Office</span>
            <span> Address</span>
        </label>
    </fieldset>
</form>

你的意思是复制与记忆相反的值吗?有点像发货地址和账单复选框一样,字段会被填充吗?