2017-05-27 17 views

答えて

0

フォームを送信する前にフォームがjqueryのを使用して提出防ぐために持っていて、値を取得し、いくつかの隠しフィールドに設定されたとjQueryてフォームを送信するために、テーブルの各列を反復処理する必要があります。

+0

uが、いくつかのサンプルコードを共有してくださいことはできますか? – Leeza

0

以下のコードは、テーブル値を反復します。これらの値は、フォーム内の入力フィールドに挿入するか、オブジェクト・フォームにフォーム・データを作成し、フォーム内の入力フィールドに設定する必要があります。

<!DOCTYPE html> 
 
<html> 
 
<head> 
 
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> 
 
<script> 
 
$(document).ready(function(){ 
 
    $("#submit").click(function(e){ 
 
     e.preventDefault(); 
 
     $("#tbody tr td").each(function(){ 
 
     \t alert($(this).text()); 
 
     }); 
 
     /* 
 
     SET VALUES EITHER IN INPUT FIELD OF FORM NEW FORM DATA AND SET IN A INPUT FIELD. 
 
     
 
     */ 
 
     $("#submit").unbind("click").click(); 
 
    }); 
 
}); 
 
</script> 
 
</head> 
 
<body> 
 
<form method="post" id="form"> 
 
<table id="table"> 
 
<thead> 
 
<tr> 
 
<th>Name</th> 
 
<th>Country</th> 
 
</tr> 
 
</thead> 
 
<tbody id="tbody"> 
 
<tr> 
 
<td>Harry</td> 
 
<td>USA</td> 
 
</tr> 
 
<tr> 
 
<td>Jonathan</td> 
 
<td>Germany</td> 
 
</tr> 
 
</tbody> 
 
</table> 
 
<input type="submit" value="submit" id="submit"/> 
 
</form> 
 
</body> 
 
</html>

関連する問題