【问题标题】:Display value of the radio button once it is selected in jsp在jsp中选择单选按钮后显示其值
【发布时间】:2016-03-25 21:11:18
【问题描述】:

我的 JSP 页面中有三个单选按钮,一旦选中,我想在单选按钮下方的 div 中显示所选按钮的值。找到下面的代码。根据选择,我想在 display 中显示值。

<div>         
      <div class="service">    
        <input type="radio" name="Service" value="Service1 Selected"      Checked>  <b>Service-1</b></input>                
       <input type="radio" name="Service" value="Service2 Selected"><b>Service-2</b></input>
       <input type="radio" name="Service" value="Service3 Selected"><b>Service-3</b></input>
    </div>
    <div class="display"></div>

【问题讨论】:

  • [link](stackoverflow.com/questions/11689530/…) 看看这个链接可能对你有帮助。
  • 谢谢,但我的要求与共享的链接不同。我不想显示该值,除非它被选中,并且该值将根据选择显示在 div 中

标签: jsp


【解决方案1】:

试试这个代码

$('input[name="Service"]').on( "click", function() {

$('.display').text($('input[name=Service]:checked').val()); });

【讨论】:

  • 谢谢,它按预期工作。最初选中了一个单选按钮,我想在页面加载后显示它。稍后它将根据选择进行更改。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-07-28
  • 1970-01-01
  • 2021-04-06
  • 2015-11-26
  • 2013-03-24
  • 1970-01-01
相关资源
最近更新 更多