1

私はjqueryを初めて使用し、次のことを実行したいと考えています。
1)ボタンがクリックされたときにフォームを生成して表示する

2)ユーザーにそのフォームのチェックボックスを使用して、電子メールの送信先を指定してもらいます

3)ダイアログボックスのすべてのチェックボックスについて、cfmailを使用してその人に電子メールを送信します(この部分を書くことができます)

以下の私のコードの冒頭をご覧ください。

<script>
$(document).ready(function() {

    $("#notifyregs").click(function() {
        var initialDiv = this;
       // HELP - set the checked box values

        var reminderemails = $(this).data("reminderemails");
        var count = 0;

        $("#editForm").dialog({ width: 500, height: 'auto', maxHeight: 1000,
            buttons: {
                "Send Emails": function() {
                    var thisDialog = $(this);
                   // HELP - Loop through reminderemails and send each value to the function sendreminders
                    $.post("tsafunctions.cfc", {
                        method: 'sendreminders',
                    reminderemails: $("#reminderemails").val(), 
                        }, 
                    function() {
                        $("#message").show();
                        $("#message").text('You sent reminders to ' + count + ' athletes');
                        $(thisDialog).dialog("close");
                    });
                }
            }
        });
    });

});
</script>

フォーム

  <div id="editForm" title="Notify Incomplete Registrations">
  Check who to send emails to:<br />
  <input type="checkbox" name="reminderemails" value="123456" checked="checked" />
  <input type="checkbox" name="reminderemails" value="234567" checked="checked" /></td>
</div>
4

2 に答える 2

2

これを試して:

selectedEmails=jQuery('#editForm :checkbox:checked').serialize();

jQuery.post には、データを渡すための data オプションがあります。

$.post("tsafunctions.cfc", {data:selectedEmails, ...});
于 2013-01-01T01:16:03.977 に答える
1

あなたのコードに基づいて、選択したチェックボックスごとに $.post 関数にリクエストを行いたいようです。シリアル化されたデータを解析したくない場合は、次のようなものが必要になります。

//--collect the checked input values and store in array
var reArr = [];
$('#editForm input:checked').each(function(){
   /*--
     pushes the value of each checkbox control that 
     is checked within the #editForm Div into and array
   --*/
  reArr.push($(this).val()); 
});

//--loop through the array and make your requests
for(var i=0; i < reArr.length; i++ ){
   /*--
    access each of the array elements using array syntax (e.g. reArr[i])
   --*/
   console.log(reArr[i]) 
   $.post("tsafunctions.cfc", {"reminderemails":reArr[i]} );
 }
 console.log(reArr);
于 2013-01-04T13:57:10.687 に答える