2010-10-27 52 views
0

我想创建2个窗体,用户可以通过点击form1和formt2来选择。如何记住输入表单值?

当用户Form 1和Form之间进行选择。我想窗口2记Form1的值和提交

选定形式的值传递这怎么能以最简单的方式来完成?

谢谢

+0

你的意思是复制而不是记住值是多少?有点像“发货地址与结算相同”复选框,并填充字段? – 2010-10-27 15:10:45

回答

0

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

您可以使用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>