2013-05-10 19 views
0

你好(我是一个完整的JS新手,所以请不要欺负) 我试图通过我的得分变量formID,但我不认为我得到我的选择权,任何人都可以告诉我,米做错了吗?如何选择一个Javascript选择器的参数?

编辑:对不起,每个人,我越来越厌倦。我的问题:我无法正确选择我的分数变量的值。

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> 
+0

您有什么问题? – SLaks 2013-05-10 22:34:43

+0

提供清楚解释您的问题的代码。你已经向我们展示了一个甚至没有关闭函数大括号的JS代码片段。 – turnt 2013-05-10 22:35:29

+0

而不是“value =”,你的意思是使用“name =”?以及使用“:checked”选择器来获取所选的输入? – Ian 2013-05-10 22:35:59

回答

3

你被选择<input>秒。您可能需要input[name=...

+0

的每个名称应该不同... – 2013-05-10 22:40:54

+0

名称不需要不同,只需使用“:checked”选择器来查找选中哪个单选按钮 – Ian 2013-05-10 22:42:54

相关问题