Jquery

버튼 토글. input 활성,비활성
  • 조회수 190
  • 작성일 2018-08-29
  •  
function chkdate(str) {
  var xxx = String(str);
  var val = $("#cdate").val();

  if(xxx == '0') {
    var base = $('.L0');
  } else if(xxx == '1') {
    var base = $('.L1');
  } else if(xxx == '2') {
    var base = $('.L2');
  } else if(xxx == '3') {
    var base = $('.L3');
  } else if(xxx == '4') {
    var base = $('.L4');
  } else if(xxx == '5') {
    var base = $('.L5');
  }

  if(val != "" && val == xxx) {
    if(val == '0') {
      var bxse = $('#L0');
    } else if(val == '1') {
      var bxse = $('#L1');
    } else if(val == '2') {
      var bxse = $('#L2');
    } else if(val == '3') {
      var bxse = $('#L3');
    } else if(val == '4') {
      var bxse = $('#L4');
    } else if(val == '5') {
      var bxse = $('#L5');
    }
    bxse.removeClass('over');
    $("#cdate").val('');
    $("#fr_date").attr("disabled", false);
    $("#to_date").attr("disabled", false);
  } else if(val != "" && val != xxx) {
    if(val == '0') {
      var bxse = $('#L0');
    } else if(val == '1') {
      var bxse = $('#L1');
    } else if(val == '2') {
      var bxse = $('#L2');
    } else if(val == '3') {
      var bxse = $('#L3');
    } else if(val == '4') {
      var bxse = $('#L4');
    } else if(val == '5') {
      var bxse = $('#L5');
    }
    bxse.removeClass('over');
    $("#cdate").val(xxx);
    base.addClass('over');
  } else {
    $("#cdate").val(xxx);
    base.addClass('over');
    $("#fr_date").val('');
    $("#to_date").val('');
    $("#fr_date").blur();
    $("#fr_date").attr("disabled", true);
    $("#to_date").attr("disabled", true);
  }
}

<input type="hidden" name="cdate" id="cdate" value="">

<tr>
<td height="50" class="idhf02" >기간별</td>
<td>
<input class="tabl0222" type="text" name="fr_date" id="fr_date" value="<?php echo $fr_date ?>" />&nbsp;&nbsp;<img src="images/main/left_02.gif" class="tabl04"/> ~
<input class="tabl0222" type="text" name="to_date" id="to_date" value="<?php echo $to_date ?>" class="tabl06" />&nbsp;&nbsp;<img src="images/main/left_02.gif" class="tabl05"/>
</td>
<td class="statistics03"><span id="L0" class="L0<?php if($cdate=="0") { echo " over"; } ?>"><a href="#none" onClick="chkdate('0')">오늘</a></span><span id="L1" class="L1<?php if($cdate=="1") { echo " over"; } ?>"><a href="#none" onClick="chkdate('1')">7일</a></span><span id="L2" class="L2<?php if($cdate=="2") { echo " over"; } ?>"><a href="#none" onClick="chkdate('2')">15일</a></span><span id="L3" class="L3<?php if($cdate=="3") { echo " over"; } ?>"><a href="#none" onClick="chkdate('3')">1개월</a></span><span id="L4" class="L4<?php if($cdate=="4") { echo " over"; } ?>"><a href="#none" onClick="chkdate('4')">3개월</a></span><span id="L5" class="L5<?php if($cdate=="5") { echo " over"; } ?>"><a href="#none" onClick="chkdate('5')">년</a></span></td>
</tr>
</table>
</li>
<li class="statistics05"><a href="statistics_01.php"><button type="submit" id="btn_submit" class="statistics04">검 색</button></a></li>


1794212158_b28a0397_C4B8C3B3.JPG