weixin_58648225 2023-01-12 21:31 采纳率: 89.2%
浏览 68
已结题

一个HTML中的的多选框问题

js在选取option下拉框id=day的项目,触发显示新的下拉多选框,多选框在整个父元素div之中无法得到期待的效果

尝试了在div父元素中的select直接赋予mutiple或者是添加div和ul元素链接js mouseleave等等函数表现都有问题。

img

目的是在"休息"的选项中选中id=day的同时在红色区域内显示html的多选下拉框,关系代码如下

<div class="inputBlock">
      <div class="subject">
        <h2>关闭</h2>
        <span class="require">关闭</span>
      </div>
      <div class="formBox">
        <div class="inner{{ $errors->hasAny('shop_open', 'shop_close') ? ' error' : '' }}">
          <div class="answerBox section">
            <label data-inline="true">
              <input type="checkbox" name="all_day_time" id="all_day_time" data-mini="true" value="on" {{ is_checked('all_day_time', 'on', $merchant->all_day_time) ? 'checked' : '' }}/>关闭
            </label>
            <div class="section">
              @php ($startTime = \Carbon\Carbon::createFromTime('00', '00'))
              @php ($endTime = \Carbon\Carbon::createFromTime('24', '00'))
              <div data-role="fieldcontain" class="section">
                <label for="business_open_time">
                  <span class="inputType">关闭</span>
                </label>
                <select name="business_open_time" id="business_open_time" data-inline="true" required>
                  <option value="">关闭</option>
                  @while ($startTime->diffInMinutes($endTime))
                    <option value="{{ $startTime->format('G:i') }}"{{ (!empty(old('business_open_time', $merchant->open_time)) && old('business_open_time', $merchant->open_time) == $startTime->format('G:i')) ? ' selected="selected"' : '' }}>{{ $startTime->format('G:i') }}</option>
                    @php ($startTime->addMinutes(30))
                  @endwhile
                </select>
                @if ($errors->has('business_open_time'))
                  @foreach ($errors->get('business_open_time') as $error)
                    <p class="errorMessage">{{ $error }}</p>
                  @endforeach
                @endif
              </div>
              <div data-role="fieldcontain" class="section">
                <label for="business_finish_time">
                  <span class="inputType">开启</span>
                </label>
                <select name="business_finish_time" id="business_finish_time" data-inline="true" required >
                  <option value="">开启</option>
                  @php ($startTime = \Carbon\Carbon::createFromTime('00', '00'))
                  @while ($startTime->diffInMinutes($endTime))
                    <option value="{{ $startTime->format('G:i') }}"{{ (!empty(old('business_finish_time', $merchant->close_time)) && old('business_finish_time', $merchant->close_time) == $startTime->format('G:i')) ? ' selected="selected"' : '' }}>{{ $startTime->format('G:i') }}</option>
                    @php ($startTime->addMinutes(30))
                  @endwhile
                </select>
                @if ($errors->has('business_finish_time'))
                  @foreach ($errors->get('business_finish_time') as $error)
                    <p class="errorMessage">{{ $error }}</p>
                  @endforeach
                @endif
              </div>
              <div data-role="fieldcontain" class="section">
                <label for="shop_close">
                  <span class="inputType">休息</span>
                </label>
                <select name="shop_close" id="shop_close" data-inline="true" required>
                  <option>休息</option>
                  <option {{old('shop_close', $appPayMerchant->regular_holiday) == "一" ? " selected" : ""}}></option>
                  <option {{old('shop_close', $appPayMerchant->regular_holiday) == "一" ? " selected" : ""}}></option>
                  <option {{old('shop_close', $appPayMerchant->regular_holiday) == "一" ? " selected" : ""}}></option>
                  <option {{old('shop_close', $appPayMerchant->regular_holiday) == "一" ? " selected" : ""}}></option>
                  <option id="day" {{old('shop_close', $appPayMerchant->regular_holiday) == "二" ? " selected" : ""}}></option>
                  <option id="day"  {{old('shop_close', $appPayMerchant->regular_holiday) == "二" ? " selected" : ""}}></option>
                  <option id="day"  {{old('shop_close', $appPayMerchant->regular_holiday) == "二" ? " selected" : ""}}></option>
                  <option id="day"  {{old('shop_close', $appPayMerchant->regular_holiday) == "二" ? " selected" : ""}}></option>
                  <option id="day"  {{old('shop_close', $appPayMerchant->regular_holiday) == "二" ? " selected" : ""}}></option>
                  <option id="day" {{old('shop_close', $appPayMerchant->regular_holiday) == "二" ? " selected" : ""}}></option>
                </select>
                @if ($errors->has('shop_close'))
                  @foreach ($errors->get('shop_close') as $error)
                    <p class="errorMessage">{{ $error }}</p>
                  @endforeach
                @endif
              </div>
            </div>
            <div class="errorMsg"></div>
            @include('merchant/form/rpay_openday_notes')
          </div>
        </div>
      </div>
      
    


还请指教在此情况下如何调出有效的多选框,非常感谢!!

  • 写回答

2条回答 默认 最新

  • CSDN专家-showbo 2023-01-12 22:07
    关注

    id为day的option有多个,只要是id是day就显示?要显示哪个dom对象?

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

问题事件

  • 系统已结题 1月21日
  • 已采纳回答 1月13日
  • 创建了问题 1月12日

悬赏问题

  • ¥15 VSCode里的Prettier如何实现等式赋值后的对齐效果?
  • ¥15 流式socket文件传输答疑
  • ¥20 keepalive配置业务服务双机单活的方法。业务服务一定是要双机单活的方式
  • ¥50 关于多次提交POST数据后,无法获取到POST数据参数的问题
  • ¥15 win10,这种情况怎么办
  • ¥15 如何在配置使用Prettier的VSCode中通过Better Align插件来对齐等式?(相关搜索:格式化)
  • ¥100 在连接内网VPN时,如何同时保持互联网连接
  • ¥15 MATLAB中使用parfor,矩阵Removal的有效索引在parfor循环中受限制
  • ¥20 Win 10 LTSC 1809版本如何无损提升到20H1版本
  • ¥50 win10 LTSC 虚拟键盘不弹出