0

こんにちは、Jquerymobile でポップアップを作成したいと考えています。私のアプリケーションでは、1 つの質問と 3 つの回答オプションがあります。ユーザーが 1 つの回答をクリックすると、ポップアップが表示されます。正しい回答の場合: これは正しいです。そして、間違った答えについて: これは間違っています。選択肢は 3 つ、2 つが不正解で 1 つが正解です。

誰か助けてくれませんか?

<fieldset data-role="controlgroup">
                <legend>
                    Question?
                </legend>
                <input type="radio" name="radio-choice-1" id="radio-choice-1" value="choice-1" checked="checked" />
                <label for="radio-choice-1">Körpergewicht / (Körpergröße)2</label>

                <input type="radio" name="radio-choice-1" id="radio-choice-2" value="choice-2"  />
                <label for="radio-choice-2">(Körpergewicht) / Körpergröße 2</label>

                <input type="radio" name="radio-choice-1" id="radio-choice-3" value="choice-3"  />
                <label for="radio-choice-3">Körpergewicht / (Alter)2</label>

            </fieldset>
        <a href="#" id="popupbut" data-role="button" data-theme="b">prüfen</a>

    <script type="text/javascript">

$(document).ready(function() {
    $(document).delegate('#popupbut', 'click', function() {
        alert($("input[name='radio-choice-1']:checked").val());
                    $('<div>').simpledialog2({
                        mode: 'blank',
                        headerText: 'Falsch',
                        headerClose: true,
                        blankContent : 

                            '<p><br /><br />This is wrong.</p>'
                    })

                });})

</script>
4

1 に答える 1

1

これで問題が解決するはずです。

  $(document).ready(function () {
            $(document).delegate('#popupbut', 'click', function () {
                var content = '';
                var headerText = '';
                if ($("input[name='radio-choice-1']:checked").val() == 'choice-1') {
                    content = '<p><br /><br />Right!.</p>'
                    headerText = 'Right';
                } else {
                    content = '<p><br /><br />Wrong!.</p>'
                    headerText = 'Wrong';
                }
                $('<div>').simpledialog2({
                    mode: 'blank',
                    headerText: headerText,
                    headerClose: true,
                    blankContent: content

                });
            });
        }); 
于 2012-07-11T09:59:15.253 に答える