リスト内のすべてのオブジェクトに隠しフィールドを追加するフォームがあり、これは foreach を使用して次のページで取得されます。それはすべて正常に動作します。
私の質問は、そのリストに別の変数を追加する必要があるということです。これまでのところ、これは日付/時刻です。同じ foreach で別の値を取得するにはどうすればよいですか?
ありがとう
フォーム:
<form action="test.php" id="calendarform" method="post">
<input type="submit" value="Export Calendar"/>
</form>
jQuery:
$('#calendarform').submit(function(e) {
var form = $(this);
var listItems = $('.listItem');
listItems.each(function(index){ //For each event do this:
var listItem = $(this);
$("<input type='hidden'/>").val(listItem.text()).appendTo(form).attr('name', 'listItem[' + index + ']');
});
応答ページ:
foreach($_POST['listItem'] as $key => $value){
$eventDate = trim($value);
}
そして最後に、どのように機能させたいですか:
foreach($_POST['listItem'] as $key => $value){
$eventDate = trim($value);
$eventTitle = trim($value2);
}