douyinzha5820 2012-10-18 06:03
浏览 38

单选按钮数组使用jquery获取id

I have a issue with radio button array. I have 1 timer when timer is 0 and select 1 radio button then that value get in jquery.

<li>
<span class="option">Option1  :  Value1 </span>  
<input type="radio" name="cmbans[][1]" id="cmbans[][1]" value="Value1" />
</li>
<li>
<span class="option">Option2  :  Value2 </span>  
<input type="radio" name="cmbans[][2]" id="cmbans[][2]" value="Value2" />
</li>
<li>
<span class="option">Option1  :  Value1 </span>  
<input type="radio" name="cmbans[][3]" id="cmbans[][3]" value="Value3" />
</li>

This radio button name or id get in jquery but problem is this is array so how can i get this. Pls help me.

Thanks in advance

  • 写回答

5条回答 默认 最新

  • douyi2664 2012-10-18 06:11
    关注

    I'm not sure what your problem is but you can't define an associative array using your inputs name attribute.
    Try

    <input type="radio" name="cmbans[]" id="cmbans_1" value="Value2" />
    <input type="radio" name="cmbans[]" id="cmbans_2" value="Value2" />
    

    You can select using jquery all elements with id starts with cmbans to get an array of radio buttons. When the form is submitted your webserver will parse the inputs names into an array.

    评论

报告相同问题?

悬赏问题

  • ¥20 机器学习能否像多层线性模型一样处理嵌套数据
  • ¥20 西门子S7-Graph,S7-300,梯形图
  • ¥50 用易语言http 访问不了网页
  • ¥50 safari浏览器fetch提交数据后数据丢失问题
  • ¥15 matlab不知道怎么改,求解答!!
  • ¥15 永磁直线电机的电流环pi调不出来
  • ¥15 用stata实现聚类的代码
  • ¥15 请问paddlehub能支持移动端开发吗?在Android studio上该如何部署?
  • ¥20 docker里部署springboot项目,访问不到扬声器
  • ¥15 netty整合springboot之后自动重连失效