0

こんにちは (私はまったくの JS 初心者ですので、いじめはご遠慮ください) スコア変数内で formID を渡そうとしていますが、セレクターが正しく動作しているとは思えません。 ?

編集:申し訳ありませんが、私は疲れています。私の問題: スコア変数の値を正しく選択できません。

JS

function addScore(formId) {
var show_id = $('#show_id-'+formId).val();  
var user_id = $('#user_id-'+formId).val();
var score = $('input[value="tvshowrating' + formID +'"]').val();

HTML

    <form id="40">
        <div class="your-score">
            <div class="">Your Score</div> <div id="flash"></div>
             <input class="hover-star" type="radio" name="tvshowrating40" value="1" title="1"  />
             <input class="hover-star" type="radio" name="tvshowrating40" value="2" title="2"  />
             <input class="hover-star" type="radio" name="tvshowrating40" value="3" title="3"  />
             <input class="hover-star" type="radio" name="tvshowrating40" value="4" title="4"  />
             <input class="hover-star" type="radio" name="tvshowrating40" value="5" title="5"  />
             <input class="hover-star" type="radio" name="tvshowrating40" value="6" title="6"  />
             <input class="hover-star" type="radio" name="tvshowrating40" value="7" title="7"  />
             <input class="hover-star" type="radio" name="tvshowrating40" value="8" title="8"  />
             <input class="hover-star" type="radio" name="tvshowrating40" value="9" title="9"  />
             <input class="hover-star" type="radio" name="tvshowrating40" value="10" title="10"  />
             <input type="hidden" id="show_id-40" value="40" /> 
             <input type="hidden" id="user_id-40" value="2" />
             <span id="hover-test" style="margin:0 0 0 20px;"></span>
             <input id="submitscore" type="submit" value="Submit scores!" onclick="addScore(40);" />  
        </div>
    </form>
</div>
4

2 に答える 2

4

おそらくチェックされた値が必要です:

$('input[name="tvshowrating' + formID +'"]:checked').val()

Here is another question that answers your problem: Get Value of Radio button group or How can I know which radio button is selected via jQuery?

于 2013-05-10T22:41:37.093 に答える
3

<input>でs を選択しています。

あなたはおそらくしたいですinput[name=...

于 2013-05-10T22:35:07.530 に答える