영보의 SystemOut.log

[Javascript] 라디오 버튼 클릭 시 value 값 변경하기 본문

Web/JS

[Javascript] 라디오 버튼 클릭 시 value 값 변경하기

영보로그 2021. 7. 19. 14:08
반응형

 라디오 버튼 클릭 시 value 값 변경하기 : datapicker로 날짜 고정값 만들기

 

조건 1. 게시 누를 때는 datapicker 코드 비활성화

 

조건 2.  게시기간 설정 누르면 자동으로 2031년 12월 31일로 설정

 

 

 

 코드

 

<script>
            // 게시기간 S일때만 기간 31/12/31까지 보이게 하기
            $('#openYes').on('click',function () {
                var valueCheck = $('#openYes:checked').val();
                if(valueCheck == 'Y' || valueCheck == 'N') {
                    $("#END_DT").val('');
                }
            });
            $('#openSet').on('click',function () {
                var valueCheck = $('#openSet:checked').val();
                if ( valueCheck == 'S') {
                    $("#END_DT").val('2031-12-31');
                }
            });
 </script>
  게시 게시 중단 게시기간설정
 value Y N S

* 스크립트 설명 

 - OpenSet(게시기간설정을)을 클릭(라디오버튼 체크) 하면 "END_DT" 자동으로 2031-12-31로 설정

 

 

 

                    <tr>
                        <th>게시여부</th>
                        <td colspan="3">
                            <label for="openYes"><input type="radio" name="OPEN_YN" value="Y" id="openYes"
                                                        checked="checked"/> 게시</label>
                            <label for="openNo"><input type="radio" name="OPEN_YN" value="N" id="openNo"/> 게시중단</label>
                            <label for="openSet"><input type="radio" name="OPEN_YN" value="S" id="openSet"/>
                                게시기간설정</label>
                            <input type="text" name="START_DT" class="txt calendar datepicker" title="시작일"/>
                            <select class="select" style="width:80px" name="START_HOUR">
                                <option value="00" selected="selected">0시</option>
                                <option value="01">1시</option>
                                <option value="02">2시</option>
                                <option value="03">3시</option>
                                <option value="04">4시</option>
                                <option value="05">5시</option>
                                <option value="06">6시</option>
                                <option value="07">7시</option>
                                <option value="08">8시</option>
                                <option value="09">9시</option>
                                <option value="10">10시</option>
                                <option value="11">11시</option>
                                <option value="12">12시</option>
                                <option value="13">13시</option>
                                <option value="14">14시</option>
                                <option value="15">15시</option>
                                <option value="16">16시</option>
                                <option value="17">17시</option>
                                <option value="18">18시</option>
                                <option value="19">19시</option>
                                <option value="20">20시</option>
                                <option value="21">21시</option>
                                <option value="22">22시</option>
                                <option value="23">23시</option>
                            </select>
                            <select class="select" style="width:80px" name="START_MINUTE">
                                <option value="00" selected="selected">0분</option>
                                <option value="01">1분</option>
                                <option value="02">2분</option>
                                <option value="03">3분</option>
                                <option value="04">4분</option>
                                <option value="05">5분</option>
                                <option value="06">6분</option>
                                <option value="07">7분</option>
                                <option value="08">8분</option>
                                <option value="09">9분</option>
                                <option value="10">10분</option>
                                <option value="11">11분</option>
                                <option value="12">12분</option>
                                <option value="13">13분</option>
                                <option value="14">14분</option>
                                <option value="15">15분</option>
                                <option value="16">16분</option>
                                <option value="17">17분</option>
                                <option value="18">18분</option>
                                <option value="19">19분</option>
                                <option value="20">20분</option>
                                <option value="21">21분</option>
                                <option value="22">22분</option>
                                <option value="23">23분</option>
                                <option value="24">24분</option>
                                <option value="25">25분</option>
                                <option value="26">26분</option>
                                <option value="27">27분</option>
                                <option value="28">28분</option>
                                <option value="29">29분</option>
                                <option value="30">30분</option>
                                <option value="31">31분</option>
                                <option value="32">32분</option>
                                <option value="33">33분</option>
                                <option value="34">34분</option>
                                <option value="35">35분</option>
                                <option value="36">36분</option>
                                <option value="37">37분</option>
                                <option value="38">38분</option>
                                <option value="39">39분</option>
                                <option value="40">40분</option>
                                <option value="41">41분</option>
                                <option value="42">42분</option>
                                <option value="43">43분</option>
                                <option value="44">44분</option>
                                <option value="45">45분</option>
                                <option value="46">46분</option>
                                <option value="47">47분</option>
                                <option value="48">48분</option>
                                <option value="49">49분</option>
                                <option value="50">50분</option>
                                <option value="51">51분</option>
                                <option value="52">52분</option>
                                <option value="53">53분</option>
                                <option value="54">54분</option>
                                <option value="55">55분</option>
                                <option value="56">56분</option>
                                <option value="57">57분</option>
                                <option value="58">58분</option>
                                <option value="59">59분</option>
                            </select>
                            <span class="t">~</span>
                                <input type="text" name="END_DT" id="END_DT" class="txt calendar datepicker" title="종료일"/>
                            <select class="select" style="width:80px" name="END_HOUR">
                                <option value="00" selected="selected">0시</option>
                                <option value="01">1시</option>
                                <option value="02">2시</option>
                                <option value="03">3시</option>
                                <option value="04">4시</option>
                                <option value="05">5시</option>
                                <option value="06">6시</option>
                                <option value="07">7시</option>
                                <option value="08">8시</option>
                                <option value="09">9시</option>
                                <option value="10">10시</option>
                                <option value="11">11시</option>
                                <option value="12">12시</option>
                                <option value="13">13시</option>
                                <option value="14">14시</option>
                                <option value="15">15시</option>
                                <option value="16">16시</option>
                                <option value="17">17시</option>
                                <option value="18">18시</option>
                                <option value="19">19시</option>
                                <option value="20">20시</option>
                                <option value="21">21시</option>
                                <option value="22">22시</option>
                                <option value="23">23시</option>
                            </select>
                            <select class="select" style="width:80px" name="END_MINUTE">
                                <option value="00" selected="selected">0분</option>
                                <option value="01">1분</option>
                                <option value="02">2분</option>
                                <option value="03">3분</option>
                                <option value="04">4분</option>
                                <option value="05">5분</option>
                                <option value="06">6분</option>
                                <option value="07">7분</option>
                                <option value="08">8분</option>
                                <option value="09">9분</option>
                                <option value="10">10분</option>
                                <option value="11">11분</option>
                                <option value="12">12분</option>
                                <option value="13">13분</option>
                                <option value="14">14분</option>
                                <option value="15">15분</option>
                                <option value="16">16분</option>
                                <option value="17">17분</option>
                                <option value="18">18분</option>
                                <option value="19">19분</option>
                                <option value="20">20분</option>
                                <option value="21">21분</option>
                                <option value="22">22분</option>
                                <option value="23">23분</option>
                                <option value="24">24분</option>
                                <option value="25">25분</option>
                                <option value="26">26분</option>
                                <option value="27">27분</option>
                                <option value="28">28분</option>
                                <option value="29">29분</option>
                                <option value="30">30분</option>
                                <option value="31">31분</option>
                                <option value="32">32분</option>
                                <option value="33">33분</option>
                                <option value="34">34분</option>
                                <option value="35">35분</option>
                                <option value="36">36분</option>
                                <option value="37">37분</option>
                                <option value="38">38분</option>
                                <option value="39">39분</option>
                                <option value="40">40분</option>
                                <option value="41">41분</option>
                                <option value="42">42분</option>
                                <option value="43">43분</option>
                                <option value="44">44분</option>
                                <option value="45">45분</option>
                                <option value="46">46분</option>
                                <option value="47">47분</option>
                                <option value="48">48분</option>
                                <option value="49">49분</option>
                                <option value="50">50분</option>
                                <option value="51">51분</option>
                                <option value="52">52분</option>
                                <option value="53">53분</option>
                                <option value="54">54분</option>
                                <option value="55">55분</option>
                                <option value="56">56분</option>
                                <option value="57">57분</option>
                                <option value="58">58분</option>
                                <option value="59">59분</option>
                            </select>
                        </td>
                    </tr>

 

 

 결과 화면

 

반응형