【问题标题】:Show particular row on selecting a checkbox在选中复选框时显示特定行
【发布时间】:2017-07-06 20:20:45
【问题描述】:

在我的表单中,当用户选择第一个包单选按钮(即 $400)时,应在步骤 2 中出现一个下拉列表,即选择字符串。

但是当任何人选择第二个包,即 550 美元时,应该会出现两个下拉列表,分别接受来自用户的两个不同输入。

Similarly when third radio button selected I need three fields and in fourth I need four dropdown lists.

我尝试了很多方法,但都没有成功。这是代码

<form name="form1" method="post" action="orderform.php">
              <table width="100%" border="1" cellpadding="5">
<tr>
                  <td colspan="2" align="center"><strong class="style2">WILSON PACKAGE INFORMATION</strong></td>
                </tr>
                <tr>
                  <td align="right" valign="top"><strong class="style1">Step1 :<br>Select your Package</strong></td>
                  <td align="left"><p>
                    <label>
                      <input type="radio" name="package" value="$400 for 2 Wilson Rackets (msrp $623)" id="package_0">
                     <strong>$400 for 2 Wilson Rackets (msrp $623)</strong>
                     <br>6 sets of Wilson or Luxilon string.
                     <br>Tour 9pk bag.
                     <br>Pro Overgrip 12 pk.</label>
                    <br><br>
                    <label>
                      <input type="radio" name="package" value="$550 for 3 Wilson Rackets (msrp $949)" id="package_1">
                      <strong>$550 for 3 Wilson Rackets (msrp $949)</strong>
                      <br>12 sets of Wilson or Luxilon string.
                     <br>Tour 15pk bag.
                     <br>Pro Overgrip 12 pk.</label>
                    <br><br>
                    <label>
                      <input type="radio" name="package" value="$675 for 4 Wilson Rackets (msrp $1256)" id="package_2">
                      <strong>$675 for 4 Wilson Rackets (msrp $1256)</strong>
                      <br>18 sets of Wilson or Luxilon string.
                     <br>Tour 15pk bag.
                     <br>Pro Overgrip 12 pk.</label>
                    <br><br>
                    <label>
                      <input type="radio" name="package" value="$800 for 5 Wilson Rackets (msrp $1562)" id="package_3">
                      <strong>$800 for 5 Wilson Rackets (msrp $1562)</strong>
                      <br>24 sets of Wilson or Luxilon string.
                     <br>Tour 15pk bag.
                     <br>Pro Overgrip 12 pk.</label>
                    <br><br>
                  </p></td>
                </tr>
                <tr>
                  <td align="right" valign="top"><strong class="style1">Step 2:<br>Choose your String</strong><br>(Must order in multiples of 6)</td>
                  <td align="left"><label for="strings"></label>
                    <select name="strings" id="strings">
                      <option selected>Choose... </option>
                      <option value="Luxilon 4G Soft ">Luxilon 4G Soft </option>
                      <option value="Luxilon 4G 125">Luxilon 4G 125 </option>
                      <option value="Luxilon 4G Rough 125">Luxilon 4G Rough 125 </option>
                      <option value="Luxilon ALU Power 125 Silver">Luxilon ALU Power 125 Silver </option>
                      <option value="Luxilon ALU Power Rough 125 Silver">Luxilon ALU Power Rough 125 Silver </option>
                      <option value="Luxilon Savage 127 Black">Luxilon Savage 127 Black </option>
                      <option value="Wilson NXT 16 ">Wilson NXT 16 </option>
                      <option value="Wilson NXT 17">Wilson NXT 17 </option>
                      <option value="Wilson Revolve 16">Wilson Revolve 16 </option>
                      <option value="Wilson Revolve 17">Wilson Revolve 17 </option>
                      <option value="Wilson Sensation 16">Wilson Sensation 16 </option>
                      <option value="Wilson Sensation 17">Wilson Sensation 17 </option>
                  </select></td>
                </tr>

【问题讨论】:

  • 您在寻找 jquery 解决方案吗?
  • 是的,这行得通。但我不太擅长。但是,如果您能提供帮助,那就太好了
  • 它工作正常吗?
  • 我无法在我的代码中应用它。你能帮忙吗?
  • 我对我的回答的评论提出了更多问题。

标签: jquery html css radio-button show-hide


【解决方案1】:

这是来自 w3schools 的教程文本: http://www.w3schools.com/jquery/jquery_hide_show.asp

$(document).ready(function(){
    $("#hide").click(function(){
        $("p").hide();
    });
    $("#show").click(function(){
        $("p").show();
    });
});

【讨论】:

  • 我在浏览答案时看到了这个,但我无法在我的代码上应用这个。
  • #hide 或 #show 是被点击的元素 ID。 P 是要显示或隐藏的元素(使用#p 表示特定的id)。
  • 您有 CDN 或预加载的缩小版 Jquery?
  • 抱歉,我无法将它与我的代码一起附加:/ 因为我对 jquery 一点也不擅长。
猜你喜欢
  • 1970-01-01
  • 2021-12-17
  • 1970-01-01
  • 2013-05-23
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-02-23
  • 1970-01-01
相关资源
最近更新 更多