0

ポップアップ ウィンドウが表示されたときに、URL に選択結果を追加する方法はありますか? 選択結果は、選択されたボックスの値を提供し、選択した値をフォームに渡したいのですが、フォームを使用していません。URL を使用して値を渡すことはできますか?

form.php?id=2882,222,22412,23 のように選択した値を追加したい

$(function() {
    $(".selectable").selectable({
        filter: "td.cs",
        stop: function() {
            var result = $("#select-result").empty();
            var result2 = $("#result2");
            $('.ui-selecting:gt(31)').removeClass("ui-selecting");
            confirmation($(".ui-selected").length + " box selected. " + ($(".ui-selected").length));
            function confirmation() {
                var answer = confirm($(".ui-selected").length + " box selected.  " + ($(".ui-selected").length));
                if (answer) {
                    window.open("form.php", "mywindow", "menubar=no,resizable=no,width=650,height=700");
                }
                else {}
            }
            $('#divmsg').html($(".ui-selected").length + " box selected")
            $('#divmsg2').html($(".ui-selected").length)
            if ($(".ui-selected").length > 90) {
                alert("Selection of only 90 boxes allowed");
                $('#divmsg').html($('#divmsg').html() + ",<br><b>Message: Selection of only 90 pixels allowed!!</b>");
                $(".ui-selected").each(function(i, e) {
                    if (i > 3) {
                        $(this).removeClass("ui-selected");
                    }
                });
                return;
            }
            $(".ui-selected", this).each(function() {
                var cabbage = this.id + ', ';
                result.append(cabbage);
            });
            var newInputResult = $('#select-result').text();
            newInputResult = newInputResult.substring(0, newInputResult.length - 1);
            result2.val(newInputResult);
        }
    });
});​

これはフィドルですhttp://jsfiddle.net/dw6Hf/57/

私が試してみました

window.open ("form.php?id="+ select-result, "mywindow",....

しかし、それはうまくいきません!! 何か案が???前もって感謝します</p>

4

2 に答える 2

1

まず、投稿したフィドルが壊れています。しかし、 http://jsfiddle.net/paragnair/dw6Hf/61/のソリューションと一緒に修正したので心配ありません。

次の行を追加しました。

var selectedIds = $.map($('.ui-selected'),function(a){ return $(a).attr('id');}).join(',');

上記の行は、クラスを持つすべての要素の ID のリストを取得しますui-selectedselectedIds次に、変数をwindow.open次のように追加できます。

window.open("form.php?id=" + selectedIds, "mywindow", "menubar=no,resizable=no,width=650,height=700");
于 2012-06-13T21:34:25.980 に答える
1

あなたが求めていると思うことを尋ねていて、selectable私が思っていることをしているなら、これを試してください:

window.open("form.php?id=" + $('#select-result').text(), "mywindow", "menubar=no,resizable=no,width=650,height=700");

それでもうまくいかない場合は、明らかにあなたの答えを誤解しています。私はそれを片付けることをお勧めします。

于 2012-06-13T21:27:47.447 に答える