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.

    评论

报告相同问题?

悬赏问题

  • ¥15 #MATLAB仿真#车辆换道路径规划
  • ¥15 java 操作 elasticsearch 8.1 实现 索引的重建
  • ¥15 数据可视化Python
  • ¥15 要给毕业设计添加扫码登录的功能!!有偿
  • ¥15 kafka 分区副本增加会导致消息丢失或者不可用吗?
  • ¥15 微信公众号自制会员卡没有收款渠道啊
  • ¥100 Jenkins自动化部署—悬赏100元
  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘