2016-07-26 6 views
2

私のシナリオによると、ユーザーは自分のプロフィール画像を提出してから、画像のURLを取得してユーザー名、性別、年齢、プロファイルのURL)をサーバーに送信します。ウェブページにネストされたhtmlフォームタグを追加する方法

nested-formsは次のコードは動作しません。だから誰かが私を解決するのを助けることができる?世界として

<form role="form" action="/submitTheProfile" method="post" > 
    <input type="text" name="fname" id="f1-first"> 
    <input type="text" name="age" id="f2-first-name"> 
    <input type="text" name="gender" id="f3-first-name"> 

    <form role="form" action="/profilePicUpload" method="post" > 

     <input id="file-0b" class="file" type="file"> 

    </form> 

</form> 
+1

[あなたはHTMLフォームをネストできますか?](http://stackoverflow.com/questions/379610/can-you-nest-html-forms) –

+0

これはあなたを助けるかもしれません。 http://stackoverflow.com/questions/597596/how-do-you-overcome-the-html-form-nesting-limitation –

+0

答えは:ajaxの助けを借りて。 – nicael

答えて

1

あなたはJavaScriptをform.so入れ子に使用することはできませんと言う

HTML

<form role="form" action="/submitTheProfile" method="post" > 
    <input type="text" name="fname" id="f1-first"> 
    <input type="text" name="age" id="f2-first-name"> 
    <input type="text" name="gender" id="f3-first-name"> 

    <input id="file-0b" class="file" type="file"> 

</form> 

Javascriptを

のように異なる方法であなたの問題を解決することができます
document.onload = function(e) { 
    var el = document.getElementById('#file-0b'); el.onchange = function(){ // your code... }; 
} 
関連する問題