2013-10-23 43 views
2

此表單實際上獲取了一些輸入字段,如下所示。添加隱藏字段,包括當前提交字段值,並將其作爲隱藏字段發送到下一頁

我需要添加輸入(隱藏)字段值和我從custom12中獲得的值,並將其作爲隱藏字段中的自定義13發送到下一頁。如何做到這一點

<form name="q9" id="submitDetails" action="pandora.do" method="post" class="form-horizontal"> 

<input type="hidden" name="cutom4" value="1" class="Qty"> 
<input type="hidden" name="cutom5" value="2" class="Qty"> 
<input type="hidden" name="cutom6" value="3" class="Qty"> 
<input type="hidden" name="cutom7" value="5" class="Qty"> 
<input type="hidden" name="cutom8" value="1" class="Qty"> 
<input type="hidden" name="cutom9" value="9" class="Qty"> 
<input type="hidden" name="cutom10" value="8" class="Qty"> 
<input type="hidden" name="cutom11" value="10" class="Qty">   

      <fieldset class="questionsForm"> 
      <div class="form-group"> 
       <div class="col-xs-10"> 
       <div class="radio"> 
        <input name="custom12" id="custom12A" value="1" type="radio" class="styled myClass prettyCheckable"> 
        <label for="custom12A">I love what I love â€「 that will never change </label> 
       </div> 
       <div class="radio"> 
        <input name="custom12" id="custom12B" value="2" type="radio" class="styled myClass prettyCheckable"> 
        <label for="custom12B">I keep an eye on the charts </label> 
       </div> 
       <div class="radio"> 
        <input name="custom12" id="custom12C" value="3" type="radio" class="styled myClass prettyCheckable"> 
        <label for="custom12C">I buy t-shirts, records and go to live shows if I like an artist. </label> 
       </div> 
       <div class="radio"> 
        <input name="custom12" id="custom12D" value="4" type="radio" class="styled myClass prettyCheckable"> 
        <label for="custom12D">I always know every word of every song and travel night and day for my artists.</label> 
       </div> 
       </div> 
      </div> 
      <div id="error_msg5">&nbsp;</div> 

      <input type="hidden" name="cutom13" value="$entrantForm32399.custom13" id="custom13">   

      <div class="clearfix">&nbsp;</div> 
      <!-- Button --> 
      <div class="form-group nextButton"> 
       <div class="col-xs-10"> 
       <button id="submitDetails" name="submitDetails" class="btn btn-primary btnNext">NEXT</button> 
       </div> 
      </div> 
      </fieldset> 
     </form> 
+1

使用PHP會議解決方案截止了? – underscore

+0

php不是在這裏使用的編程語言 –

+0

服務器端腳本(通常是php)是對錶單進行響應的好方法。正如Rohan所說,你可以使用其他方法,比如cookies。 – bjb568

回答

0

中包含

$("#submitDetails").submit(function(event) { 

    var c1 = parseInt($(this).find('input[name="custom4"]').val()); 
    var c2 = parseInt($(this).find('input[name="custom5"]').val()); 
    var c3 = parseInt($(this).find('input[name="custom6"]').val()); 
    var c4 = parseInt($(this).find('input[name="custom7"]').val()); 
    var c5 = parseInt($(this).find('input[name="custom8"]').val()); 
    var c6 = parseInt($(this).find('input[name="custom9"]').val()); 
    var c7 = parseInt($(this).find('input[name="custom10"]').val()); 
    var c8 = parseInt($(this).find('input[name="custom11"]').val()); 

    var radioInput = parseInt($(this).find('input[name="custom12"]:checked').val()); 

    var total = c1+c2+c3+c4+c5+c6+c7+c8+radioInput; 

    $('#finalvalue').val(total); 

    $test = $('#finalvalue').val(); 

}); 
1

您可以使用localstorageCookies從一個頁面發送數據的另一種使用javascript來。

一樣,

$'#submitDetails').on('click',function(){ 
    localStorage.setItem('formData',$('#submitDetails').serialize()); 
    $('#submitDetails').submit(); 
    // set form data to local storage 
}); 

serialize()

另外,你可以試試這個,

首先改變你的formid,作爲id必須unique和你buttonform bot h有相同的id

$("#submitDetails").on('click',function(event) {  
    var c4 = parseInt($('input[name="custom4"]').val()); 
    var c5 = parseInt($('input[name="custom5"]').val()); 
    var c6 = parseInt($('input[name="custom6"]').val()); 
    var c7 = parseInt($('input[name="custom7"]').val()); 
    var c8 = parseInt($('input[name="custom8"]').val()); 
    var c9 = parseInt($('input[name="custom9"]').val()); 
    var c10 = parseInt($('input[name="custom10"]').val()); 
    var c11 = parseInt($('input[name="custom11"]').val());  
    var radioVal= parseInt($('input[name="custom12"]:checked').val());  
    var total = c4 + c5 + c6 + c7 + c8 + c9 + c10 + c11 + radioVal;  
    $('#custom13').val(total);// send this value to next form  
});