2

此表单实际上正在获取一些输入字段,如下所示。

我需要添加输入(隐藏)字段值和我从 custom12 获得的值,并在隐藏字段中作为 custom 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>
4

2 回答 2

1

您可以使用localstorageCookie将数据从一个页面发送到另一个页面javascript

像,

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

读取序列化()

或者,你可以试试这个,

首先改变idyour 的form, as idmust be uniqueand your buttonand formboth have the same 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    
});
于 2013-10-23T05:11:36.880 回答
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();

});
于 2013-11-02T05:27:55.030 回答