duanmiyang6201 2015-02-16 13:18
浏览 31

Javascript onchange下拉助手

I am trying a javascript onchange method I am new in coding. What I want when I select ID Type the input text to change to passport and when I select South African ID the input to change to South African ID here is a code. The passport field its hidden once I select a password, South African ID must change in the passport

 <div class="editor-label"><label for="IDType">ID Type:</label></div>
    <div class="editor-field"><select class="editor-dropdown" id="IdType" name="IDType">
    <option value="SouthAfricanId">South African ID</option>
    <option value="Passport">Passport</option>
    <input id="Passport" name="Passport" type="hidden" value="True">           
    </div>
    <div class="editor-label">
    <label id="lbIDValue">South African ID:</label>
    </div>
    <div class="editor-field">
    <input class="textbox" id="txIdValue" maxlength="13" name="IDValue" type="text" value="">
    </div>
  • 写回答

2条回答 默认 最新

  • dongtan7639 2015-02-16 13:27
    关注

    You could try the JQuery below:

    $("#IdType").change(function(){
        $("#lbIDValue").val($(this).find("option:selected").text());
        if($(this).val() == "passport"){
            $('#Passport').hide();
        }
        else{
            $('#Passport').show();
        }
    })
    
    评论

报告相同问题?

悬赏问题

  • ¥15 使用ue5插件narrative时如何切换关卡也保存叙事任务记录
  • ¥20 软件测试决策法疑问求解答
  • ¥15 win11 23H2删除推荐的项目,支持注册表等
  • ¥15 matlab 用yalmip搭建模型,cplex求解,线性化处理的方法
  • ¥15 qt6.6.3 基于百度云的语音识别 不会改
  • ¥15 关于#目标检测#的问题:大概就是类似后台自动检测某下架商品的库存,在他监测到该商品上架并且可以购买的瞬间点击立即购买下单
  • ¥15 神经网络怎么把隐含层变量融合到损失函数中?
  • ¥15 lingo18勾选global solver求解使用的算法
  • ¥15 全部备份安卓app数据包括密码,可以复制到另一手机上运行
  • ¥20 测距传感器数据手册i2c