1

我有一个jsp文件:

<div class="span12" id="result" style="position: relative; top:-57px;margin-left:-10px">
 Is The Image Missing or Wrong?
<table>
 <tr>
  <td>
   <input type="radio" name="imageprob" value="Missing" onclick="MissingSelected()">
     Missing 
     <br>
     <input type="radio" name="imageprob" value="Wrong" onclick="WrongSelected()">Wrong
  </td>
  <td></td> //content of this column to be set based on which radio button slected
 </tr>
</table>
</div>  
</div>

我想根据在第一列中选​​择的单选按钮设置表中第二列的内容。我该怎么做?

4

3 回答 3

2

试试这个兄弟| 检查这个 演示

HTML

<div class="span12" id="result" style="position: relative; top:-57px;margin-left:-10px">
      Is The Image Missing or Wrong?
      <table><tr>
      <td><input type="radio" name="imageprob" value="Missing" onclick="selected(this)"> Missing 
<br>
      <input type="radio" name="imageprob" value="Wrong" onclick="selected(this)">Wrong</td>
      <td id="set"></td> //content of this column to be set based on which radio button slected
      </tr></table>
    </div>  
    </div>

JS

function selected(dis)
{
    var ele= document.getElementById('set');
    if(dis.value =='Missing')
    {
     ele.innerHTML ="MIssing something";   
    }
    else    
    {
     ele.innerHTML ="Correct";   
    }
}
于 2013-10-01T05:53:50.010 回答
1

jquery当用户选择单选按钮调用将填充数据并显示在特定表/div中的其他页面时使用。

<input type="radio" name="lom" value="1" checked> first
<input type="radio" name="lom" value="2"> second


$("input[@name='lom']").change(function(){
    $.get( "ajax/test.html", function( data ) {
       $( ".result" ).html( data );
       alert( "Load was performed." );
    });
});

http://api.jquery.com/jQuery.get/

于 2013-10-01T05:46:55.840 回答
1

您可以使用 Jquery 并像这样设置 column2-value:

$('input[name="imageprob"]').change(function(){
    var radioVal = $(this).val();
    var column2El = $('div#result > table td:nth-child(2)');
    if('Missing' === radioVal){
        alert('Missing');
        column2El.text('Missing');
    } else if('Wrong' === radioVal){
        alert('Wrong');
        column2El.text('Wrong');
    }
});

这特定于您提供的代码,并且将为您工作。

于 2013-10-01T06:03:15.773 回答