2016-08-12 10 views
0

のボタンを使用して外部のフォームからフォームを送信するためにどのように私は私が私のng-click書かれている私は角</p> <p>使用<code>next()</code>と<code>saveStep()</code>にフォームを送信する必要があるHTML

フォーム内next()saveStep()を書き込むことはできません以下

next()saveStep()のために、私はその作業のフォームの内側からフォームをsubmitingていたときに罰金

これは、これがされていないトークン

<div class="content"> 
    <div class="content_wrap"> 
    <div class="content_title centered">Order an SOA</div> 
    <div class="card"> 
     <div class="card_title title_custom">PAYMENT 
     <div>Please provide credit card details</div> 
     </div> 

     <div class="form_element table_wrap"> 
     <table class="form_element_table center-aligned right-border"> 
      <thead> 
      <th class="no-background">Order Summary</th> 
      <th class="no-background">Credit Card Details</th> 
      </thead> 
      <tbody> 
      <tr> 
       <td> 
       <div class="inner-table-element"> 
        <div class="inner-table-cell">Advice - SMSF Establishment</div> 
        <div class="inner-table-cell small">$ {{smf_Fee}}</div> 
       </div> 
       <div class="inner-table-element"> 
        <div class="inner-table-cell">Advice - Property in Super</div> 
        <div class="inner-table-cell small">$ {{buy_property_Fee}}</div> 
       </div> 
       <div class="inner-table-element top-border"> 
        <div class="inner-table-cell">Total</div> 
        <div class="inner-table-cell small">$ {{totalFee}}</div> 
       </div> 
       </td> 
       <!--<td>--> 
       <!--<div class="inner-table-element front-space">--> 
       <!--<div class="inner-table-cell">Card Number</div>--> 
       <!--<div class="inner-table-cell align-right"><input type="text" ng-model="step6.cardNumber"/></div>--> 
       <!--</div>--> 
       <!--<div class="inner-table-element front-space">--> 
       <!--<div class="inner-table-cell">CVC</div>--> 
       <!--<div class="inner-table-cell align-right"><input type="text" ng-model="step6.cvc"/></div>--> 
       <!--</div>--> 
       <!--<div class="inner-table-element front-space">--> 
       <!--<div class="inner-table-cell">Expiry (MM/YY)</div>--> 
       <!--<div class="inner-table-cell align-right"><input type="text" ng-model="step6.expiry"/></div>--> 
       <!--</div>--> 
       <!--</td>--> 
       <td> 
       <form action="/plan/account/charge" method="POST" id="payment-form"> 
        <div class="inner-table-element front-space"> 
        <div class="inner-table-cell">Card Number</div> 
        <div class="inner-table-cell align-right"> 
         <input class="card_number" type="text" size="20" data-stripe="number" placeholder="Card Number" /> 
        </div> 
        </div> 
        <div class="inner-table-element front-space"> 
        <div class="inner-table-cell">CVC</div> 
        <div class="inner-table-cell align-right"> 
         <input class="cvc" type="text" size="4" data-stripe="cvc" placeholder="CVC" /> 
        </div> 
        </div> 
        <div class="inner-table-element front-space"> 
        <div class="inner-table-cell">Expiry</div> 
        <div class="inner-table-cell align-right"> 
         <input class="payment_text exp_month expiry" type="text" size="2" data-stripe="exp-month" placeholder="MM" /> 
         <span>/</span> 
         <input class="payment_text exp_year expiry" type="text" size="4" data-stripe="exp-year" placeholder="YYYY" /> 
        </div> 
        </div> 
       </form> 
       </td> 
      </tr> 
      <tr> 
       <td> 
       </td> 
       <td> 
       </td> 
      </tr> 
      </tbody> 
     </table> 
     </div> 

     <div class="form_element nav_btn_wrap"> 
     <div class="btn back-btn" ng-click="back();"> 
      <span>Back</span> 
     </div> 
     <div class="btn next-btn" ng-click="saveStep();"> 
      <span>Save</span> 
     </div> 
     <div class="btn next-btn" ng-click="next();"> 
      <span>Next</span> 
     </div> 
     </div> 

    </div> 
    </div> 
</div> 
accountantApp.controller("step6Controller", function($rootScope, $scope, $http, $location) { 

    $scope.buy_property_Fee = $rootScope.soaFormData["step1"].buy_property_Fee; 
    $scope.smf_Fee = $rootScope.soaFormData["step1"].smf_Fee; 
    $scope.totalFee = $rootScope.soaFormData["step1"].totalFee; 
    $scope.step6 = { 
    cardNumber: "", 
    cvc: "", 
    expiry: "" 
    } 
    $scope.back = function() { 
    $scope.onBacKEvent(); 
    }; 
    $scope.saveStep = function() { 
    var count = 0; 
    $(".form_element_table input").each(function() { 
     if ($(this).val() == "") { 
     $(this).css({ 
      "border": "1px solid red" 
     }); 
     } else { 
     $(this).css({ 
      "border": "1px solid #CDC5C5" 
     }); 
     count++; 
     } 
    }); 
    if (count != $(".form_element_table input").length) { 
     $.toast({ 
     heading: 'Error', 
     text: 'Please fill the fields', 
     showHideTransition: 'fade', 
     icon: 'error' 
     }); 
     return; 
    } 
    $rootScope.soaFormData["step6"] = $scope.step6; 
    $rootScope.stepsCompleted.push("step6"); 

    $rootScope.saveSoa(function(data, status, headers, config) {}); 
    }; 
    $scope.next = function() { 

    var count = 0; 
    $(".form_element_table input").each(function() { 
     if ($(this).val() == "") { 
     $(this).css({ 
      "border": "1px solid red" 
     }); 
     } else { 
     $(this).css({ 
      "border": "1px solid #CDC5C5" 
     }); 
     count++; 
     } 
    }); 
    if (count != $(".form_element_table input").length) { 
     $.toast({ 
     heading: 'Error', 
     text: 'Please fill the fields', 
     showHideTransition: 'fade', 
     icon: 'error' 
     }); 
     return; 
    } 
    $rootScope.soaFormData["step6"] = $scope.step6; 
    $rootScope.stepsCompleted.push("step6"); 
    $location.path("/step7"); 
    }; 
}); 
+0

あなたの入力にNG-モデルを置く場合は、送信ボタンをどこに置いたか、それは問題ではないだろう。 –

+0

@RaniRadcliffはい、 'はネストされたフォームを送信しますので、問題はありません。' 'それでどこに置いても問題ありませんが、' doSubmit'関数は 'ng-modeled'データを提出する作業をする必要があります。 – plong0

答えて

1

リファレンス

Submit form using a button outside the <form> tagにメモを生成するためのストライプのためのコードがあるMYからコードITSは次のとおりです。それはこの

ようになります http://jsfiddle.net/erdt761h/

<html> 
<head> 
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script> 
<style> 
.hidden{ 
    display: none; 
} 
</style> 
</head> 
<body> 
<form method="get" action="http://www.google.com/search" target="_blank"> 
    <input type="text" name="q" /> 
    <input type="submit" id="submit-form" class="hidden" /> 
</form> 

<label for="submit-form">ProxyButton</label> 

</body> 
<script> 


</script> 
</html> 

彼/彼女のユーザーが(現在のところ) "クマール"である他のページにこれを書いた人々に信用を与える。 しかし、コードの一般的なアイデアは、cssによって隠されたサブミットボタンをまだ持っていて、それをボタンを使ってスタイルすることができるラベルを介してやり取りされます。もう1つのページでは、送信ボタンをCSSで移動してフォームの外に見えるようにする方法についても話しました。

0

Core JS DOMフォームオブジェクトにはsubmit()という機能があります。

あなたのnext()saveStep()機能に追加してみてください:

document.getElementById('payment-form').submit(); 
+0

これは質問に対する答えを提供しません。批評をしたり、著者の説明を求めるには、投稿の下にコメントを残してください。 - [レビューの投稿](レビュー/低品質の投稿/ 13312686) – eisbehr

+0

@eisbehr私は少し答えを広げました。私はそれが直接的かつ簡潔に質問に答えると感じます。 – plong0

関連する問題

 関連する問題