第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

jQuery 表單提交按鈕根據(jù)所選復(fù)選框轉(zhuǎn)到 URL

jQuery 表單提交按鈕根據(jù)所選復(fù)選框轉(zhuǎn)到 URL

函數(shù)式編程 2023-10-24 20:00:33
我有一個(gè)帶有多個(gè)復(fù)選框的簡(jiǎn)單聯(lián)系表單,當(dāng)用戶選擇一個(gè)復(fù)選框時(shí),它應(yīng)該轉(zhuǎn)到與值中的 url 綁定的 url/文件夾。當(dāng)前的問(wèn)題是,當(dāng)用戶選中復(fù)選框并單擊“提交”,然后返回到該頁(yè)面并且復(fù)選框重置后,提交按鈕仍然會(huì)將他們帶到之前選擇的復(fù)選框。需要一種方法來(lái)完全重置表單并禁用按鈕,以便提交不會(huì)讓用戶感到太困惑。謝謝!這是我的表單代碼:<form name="frm" id="myForm" method="post" >  <div class="provider-checkboxes">    <input type="checkbox" name="rGroup" id="r1" value="folder-1/" onclick="formaction(this)"/>    <label class="check-div" for="r1">Label 1</label>    <input type="checkbox" name="rGroup" id="r2" value="folder-2/" onclick="formaction(this)"/>    <label class="check-div" for="r2">Label 2</label>    <input type="checkbox" name="rGroup" id="r3" value="folder-3/" onclick="formaction(this)"/>    <label class="check-div" for="r3">Label 3</label>    <button type="submit" class="btn btn-primary btn-lg btn-block">Next</button>  </div></form>這是腳本:$(document).ready(function(){  $('input[type="checkbox"]').click(function(){    var inputValue = $(this).attr("value");    $("." + inputValue).toggle();  });});$('[data-toggle="btns"] .btn').on('click', function(){  var $this = $(this);  $this.parent().find('.active').removeClass('active');  $this.addClass('active');});$('.selectme input:checkbox').click(function() {  $('.selectme input:checkbox').not(this).prop('checked', false);});  $('.provider-checkboxes input:checkbox').click(function() {  $('.provider-checkboxes input:checkbox').not(this).prop('checked', false);}); function formaction(checkbox){  document.getElementById("myForm").action = checkbox.value;;}function UncheckAll(){   var w = document.getElementsByTagName('input');   for(var i = 0; i < w.length; i++){     if(w[i].type=='checkbox'){       w[i].checked = false;     }  }}
查看完整描述

1 回答

?
SMILET

TA貢獻(xiàn)1796條經(jīng)驗(yàn) 獲得超4個(gè)贊

考慮以下代碼。根據(jù)您分享的內(nèi)容,認(rèn)為這會(huì)有所幫助。


$(function() {

  function setFormAction(frm, a) {

    frm.attr("action", a);

  }


  function unCheckAll() {

    $("input[type='checkbox']").prop("checked", false);

    $(".provider-checkboxes .btn").hide();

  }


  $('.provider-checkboxes input:checkbox').click(function() {

    unCheckAll();

    $(this).prop("checked", true);

    $(".provider-checkboxes .btn").toggle(300);

    setFormAction($("#myForm"), "./" + $(this).val());

    console.log($("#myForm")[0]);

  });


  unCheckAll();

});

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>

<form name="frm" id="myForm" method="post">

  <div class="provider-checkboxes">

    <input type="checkbox" name="rGroup" id="r1" value="folder-1/" />

    <label class="check-div" for="r1">Label 1</label>

    <input type="checkbox" name="rGroup" id="r2" value="folder-2/" />

    <label class="check-div" for="r2">Label 2</label>

    <input type="checkbox" name="rGroup" id="r3" value="folder-3/" />

    <label class="check-div" for="r3">Label 3</label>

    <button type="submit" class="btn btn-primary btn-lg btn-block">Next</button>

  </div>

</form>


查看完整回答
反對(duì) 回復(fù) 2023-10-24
  • 1 回答
  • 0 關(guān)注
  • 136 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)