2021年2月5日星期五

How can I choose the option in the selectbox according to the data that comes with the get method?

function getUrlVars(){    var vars = {};    var parts = window.location.href.replace(/[?&]+([^=&]+)=([^&]*)/gi, function(m,key,value){        vars[key] = value;    });    return vars;  }    var getBt = getUrlVars()["bt"];  

According to the getBt variable here, how can I do 'checked' from the options below to the value equal to value?

So, for example, if the value of getBt is 2, I want to select the radio option with value 2.

<div class="card-body">      <label class="custom-control custom-radio">          <input type="radio" name="Filter[type][]" checked="" value="0" class="custom-control-input">          <div class="custom-control-label">All</div>      </label>      <label class="custom-control custom-radio">          <input type="radio" name="Filter[type][]" value="1" class="custom-control-input">          <div class="custom-control-label">option1</div>      </label>      <label class="custom-control custom-radio">          <input type="radio" name="Filter[type][]" value="2" class="custom-control-input">          <div class="custom-control-label">option2</div>      </label>      <label class="custom-control custom-radio">          <input type="radio" name="Filter[type][]" value="3" class="custom-control-input">          <div class="custom-control-label">option3</div>      </label>  </div>
https://stackoverflow.com/questions/66073329/how-can-i-choose-the-option-in-the-selectbox-according-to-the-data-that-comes-wi February 06, 2021 at 11:34AM

没有评论:

发表评论