function tosub(st){     $('#uup').html(st);
}<logic:notEmpty name="AP3510BeanList" >
<logic:iterate id="bean" name="AP3510BeanList" indexId="i">
<tr>
<td width="80%" align="center" class="tr_color_1">
                  <bean:write name="bean" property="replay"/>
</td>
    <td width="20%" align="center">
               <span id="uup"></span><input onclick="tosub('1')"type="button" value="提交" />
                </td>
</tr>
</logic:iterate>
</logic:notEmpty>
我提交的button按钮是循环的,有多个,当我提交后,我提交的值===1,通过jquery添加到 <span>里:$('#uup').html(st);
,但是我每个提交的值总是赋值到循环的第一个上面,我想每个提交按钮都有对应的<span>但是我不管提交哪个按钮,它的值总是赋值第一个<span>上面,但是我刷新后,其实真正的值还是赋值到该按钮的上面,我想每点击单个提交按钮,但是它的值对应该<span>,请教怎么解决!!!!!!!!!!

解决方案 »

  1.   

    没看懂楼主想要啥效果啊 =_=不过,你应该考虑下给每个span一个id,比如 uup1, uup2, uup3
      

  2.   

    因为ID是唯一的,不允许有重复的,当有多个相同的ID时,只有第一个有用
    你可以在ID里面加个参数,防止ID重复
      

  3.   

    那怎么定义活的变量,我用juqery比如
    $('#uup_'+r_id).html(1);我的意思是把这个变量定义活得,r_id是每个属性的ID,但是不juqery不能这样搞
    <logic:notEmpty name="AP3510BeanList" >
            <logic:iterate id="bean" name="AP3510BeanList" indexId="i">
                <tr>
                    <td width="80%" align="center" class="tr_color_1">
                      <bean:write name="bean" property="replay"/>
                    </td>
                    <td width="20%" align="center">
                   <span id="uup_<bean:write name="bean"  property="r_id"/>"></span><input onclick="tosub('1')"type="button" value="提交" />
                                   </td>
                </tr>
            </logic:iterate>
            </logic:notEmpty>
      

  4.   

    那怎么定义活的变量,我用juqery比如
    $('#uup_'+r_id).html(1);我的意思是把这个变量定义活得,r_id是每个属性的ID,但是不juqery不能这样搞
    <logic:notEmpty name="AP3510BeanList" >
            <logic:iterate id="bean" name="AP3510BeanList" indexId="i">
                <tr>
                    <td width="80%" align="center" class="tr_color_1">
                      <bean:write name="bean" property="replay"/>
                    </td>
                    <td width="20%" align="center">
                   <span id="uup_<bean:write name="bean"  property="r_id"/>"></span><input onclick="tosub('1')"type="button" value="提交" />
                                   </td>
                </tr>
            </logic:iterate>
            </logic:notEmpty>
      

  5.   

    你可以这样:
    $('#uup_'+<bean:write name="bean"  property="r_id"/>).html(1);
      

  6.   

    5楼的同学,没这么麻烦,只需要:function tosub(st){
         $('#uup' + st).html(st);