简体   繁体   English

从下拉列表中选择其他选项时激活文本框

[英]activate a textbox on selecting other option from dropdown list

I need help with my email order form. 我的电子邮件订购表需要帮助。

When someone selects the "Self-Collection" option, it will make the date and time selection active for the user. 当有人选择“自收集”选项时,它将使用户选择日期和时间。 And I want to make the date and time selection a required field. 我想将选择日期和时间作为必填字段。 How can I do it? 我该怎么做?

And also please visit the link here . 另外,请访问此处链接

After adding the code below, the email cannot be sent. 添加以下代码后,将无法发送电子邮件。

   <div class="section colm colm6">
   <label class="field select">
   <select name="select" id="select">
    <option value="">Delivery Methods...</option>
                                    <option value="Register-Mail">     Register Mail </option>
                                    <option value="Normal-Mail"> Normal Mail </option>
                                    <option value="Self-Collection">   Self-Collection </option>
                                    <option value="QVOO-Delivery"> QVOO Delivery (+$8) </option>
   </select>
    <i class="arrow double"></i>                    
                            </label>  
  </div>


                </div><!-- end frm-row section -->
                <center><strong><p>**WE will re-confirm your self collection date once your order arrives</p></strong></center>
       <div class="section colm colm6">
                   <label class="field select">
                       <select id="Self-Collection" name="Self-Collection" disabled='disabled'>
                           <option value="">Self Collection Date...        </option>
                           <option value="Monday After 7pm">Monday After 7pm</option>
                           <option value="Wednesday After 7pm"> Wednesday After 7pm </option>
                           <option value="Friday After 7pm"> Friday After 7pm </option>
                           <option value="Saturday Day 9am-2pm"> Saturday Day 9am-2pm </option>
                           <option value="Sunday 9am-2pm"> Sunday 9am-2pm </option>
                       </select>
                       <i class="arrow double"></i>                    
                   </label>  
                  </div>


      $(document).ready(function () {
     $("#select").change(function () {
    if ($(this).find("option:selected").val() == "Self-Collection") {
        $("#Self-Collection").removeAttr("disabled")
    } else {
        $("#Self-Collection").attr("disabled","disabled")
    }
     });
    });

have you tried placing required attribute on your select button. 您是否尝试过将必填属性放置在选择按钮上。

I have edited my answer. 我已经编辑了答案。 Please check. 请检查。

$(document).ready(function () {
  $("#select").change(function () {
  if ($(this).find("option:selected").val() == "Self-Collection") {
    $("#Self-Collection").removeAttr("disabled");
    $("#Self-Collection").attr("required","true");
  } else {
    $("#Self-Collection").attr("disabled","disabled");
    $("#Self-Collection").removeAttr("required");
  }
  });
});

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 我想从下拉列表中选择其他选项时激活一个文本框,否则它将保持不活动状态 - I want to activate a textbox on selecting other option from dropdown list only else it remains inactive 从选择下拉菜单中选择一个选项时,请禁用其他字段 - disable other fields when selecting a option from select dropdown 将其他选项的值添加到下拉列表 - Add value from other option to a dropdown list jQuery,通过文本框值从下拉列表中设置一个选项 - Jquery, Set an option from dropdown list by a textbox value 通过选择其他下拉列表的选项,将列表填充到下拉列表中,但完整的列会在表格中获取该行的选项 - List is populated into a dropdown, by selecting an option of other dropdown, but the complete column gets that row's options in a table 从for循环中选择一个下拉选项 - Selecting a dropdown option from a for loop 如果我在下拉框中选择其他选项,如何激活文本框 - how to activate a textbox if I select an other option in drop down box 选择下拉选项后无法填充输入文本框 - Trouble populating input textbox after selecting dropdown option 从下拉列表中选择一个值时,将其他下拉列表设置为其默认值 - when selecting a value from a dropdown list set other dropdown list to it's default value 如何在表中该行的其他可用下拉列表中显示从下拉列表中取消选择的选项-jQuery - how to show the deselected option from the dropdown list in the other available dropdown list of that row in a table - jquery
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM