1 Replies - 101 Views - Last Post: 06 July 2018 - 04:43 AM

#1 naveenlb   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 06-July 18

Issue with if condition.

Posted 06 July 2018 - 04:37 AM

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="parent">

  <!--Parent 1 Radio start-->
  <div class="init-radio-parent">
    <input type="radio" name="radios-init">
    <label for="radios-init">One</label>
    <input type="radio" name="radios-init">
    <label for="radios-init">two</label>
    <input type="radio" name="radios-init">
    <label for="radios-init">three</label>
  </div>
  <!--Parent 1 Radio end-->

  <!--Parent 1 text input start-->
  <div class="text-field-init">
    <input type="text" id="init-one-id" class="init-one-text" name="init-one-text" maxlength="1/">
    <input type="text" id="init-two-id" class="init-one-text" name="init-one-text" maxlength="1/">
    <input type="text" id="init-three-id" class="init-one-text" name="init-one-text" maxlength="1/">
    <i class="fa fa-info-circle" aria-hidden="true"></i>
  </div>
  <!--Parent 1 text input end-->

</div>

<br><br>

<!--Parent 2 text radio start-->
<div class="graph-radio">
  <input type="radio" name="graph-init">
  <label for="graph-init">GOne</label>
  <input type="radio" name="graph-init">
  <label for="graph-init">GTwo</label>
</div>
<!--Parent 2 text radio end-->

<br><br>

<div class="add-to-bag-section">
  <input type="text">
  <input type="submit">
</div>




var init_txt = $(".init-one-text");
var init_radio_btn = document.querySelector('input[name="radios-init"]:checked') != null ? document.querySelector('input[name="radios-init"]:checked').value : "";
var graph_radio_btn = document.querySelector('input[name="graph-init"]:checked') != null ? document.querySelector('input[name="graph-init"]:checked').value : "";

if ((init_radio_btn != '' && init_txt.length > 1) || graph_radio_btn != '') {

  $('.add-to-bag-section input[type=text], .add-to-bag-section input[type=submit]').attr('readonly', false);
  $('.add-to-bag-section input[type=text], .add-to-bag-section input[type=submit]').attr('disabled', false);

} else {
  $('.add-to-bag-section input[type=text], .add-to-bag-section input[type=submit]').attr('readonly', true);
  $('.add-to-bag-section input[type=text], .add-to-bag-section input[type=submit]').attr('disabled', true);
}



I tried few solutions from stack overflow but didn't seem to be working.

Is This A Good Question/Topic? 0
  • +

Replies To: Issue with if condition.

#2 Dormilich   User is offline

  • 痛覚残留
  • member icon

Reputation: 4208
  • View blog
  • Posts: 13,283
  • Joined: 08-June 10

Re: Issue with if condition.

Posted 06 July 2018 - 04:43 AM

Quote

I tried few solutions


What is the problem at hand? This isn't a Jeopardy forum ...
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1