라디오 버튼(자바스크립트)을 이용한 구매자/판매자 폼 각각 다르게 나타내기

라디오 버튼(자바스크립트)을 이용한 구매자/판매자 폼 각각 다르게 나타내기

QA

라디오 버튼(자바스크립트)을 이용한 구매자/판매자 폼 각각 다르게 나타내기

본문

<tr>

            <th scope="row"><label for="wr_subject">제목<strong class="sound_only">필수</strong></label></th>

            <td>

                <div id="autosave_wrapper">

                    <input type="text" name="wr_subject" value="<?php echo $subject ?>" id="wr_subject" required class="frm_input required" size="50" maxlength="255">

                    <?php if ($is_member) { // 임시 저장된 글 기능 ?>

                    <script src="<?php echo G5_JS_URL; ?>/autosave.js"></script>

                    <?php if($editor_content_js) echo $editor_content_js; ?>

                    </div>

                    <?php } ?>

                </div>

            </td>

            <th scope="row"><label for="wr_10">구분</label></th>

            <td>

                <input type="radio" name="wr_10" id="wr_10" value="판매자" onclick="RadioChk('Radio_On');"/>판매자

                <input type="radio" name="wr_10" id="wr_10" value="구매자" onclick="RadioChk('Radio_Off');"/>구매자

            </td>

        </tr>

    

        <tr id="Radio_On" style="display:'';">

            <th scope="row"><label for="wr_1">판매자</br>(기업/단체)</label></th>

            <td>

                <input type="text" name="wr_1" value="<?=$write['wr_1']?>" size="50" maxlength="255"/>

            </td>

            <th scope="row"><label for="wr_2">전화번호</label></th>

            <td>

                <input type="text" name="wr_2" value="<?=$write['wr_2']?>" size="50" maxlength="255"/>

            </td>

        </tr>

 

        <tr id="Raio_Off" style="display:'';">

            <th scope="row"><label for="wr_8">구매자</br>(기업/단체)</label></th>

            <td>

                <input type="text" name="wr_8" value="<?=$write['wr_8']?>" size="50" maxlength="255" />

            </td>

            <th scope="row"><label for="wr_2">전화번호</label></th>

            <td>

                <input type="text" name="wr_2" value="<?=$write['wr_2']?>" size="50" maxlength="255"/>

            </td>

            

        </tr>

 

        <tr>

            <th scope="row"><label for="wr_3">이메일</label></th>

            <td>

                <input type="text" name="wr_3" value="<?=$write['wr_3']?>" size="50" maxlength="255"/>

            </td>

            <th scope="row"><label for="wr_4">상품</label></th>

            <td>

                <input type="text" name="wr_4" value="<?=$write['wr_4']?>" size="50" maxlength="255"/>

            </td>

        </tr>

 

        <tr>

            <th scope="row"><label for="wr_5">가격</label></th>

            <td>

                <input type="text" name="wr_5" value="<?=$write['wr_5']?>" size="50" maxlength="255"/>

            </td>

            

        </tr>

            

        <tr>

            <th scope="row" ><label for="wr_6">배송방법</label></th>

            <td>

                <input type="text" name="wr_6" value="<?=$write['wr_6']?>" size="50" maxlength="255"/>

            </td>

            <th scope="row"><label for="wr_7">결제방법</label></th>

            <td>

                <input type="text" name="wr_7" value="<?=$write['wr_7']?>" size="50" maxlength="255"/>

            </td>

        </tr>

        

 

        <tr>

            <th scope="row"><label for="wr_content">상품설명<strong class="sound_only">필수</strong></label></th>

           

               </tbody>

        </table>

    </div>

 

-------------------------------------------------------------------------------

 

function RadioChk(id) {

            if(id=="Radio_On") {

                document.all("Radio_On").style.display = '';

                document.all("Radio_Off").style.display = 'none';

            } else {

                document.all("Radio_On").style.display = 'none';

                document.all("Radio_Off").style.display = '';

            }

        }

--------------------------------------------------------------------------

 

그누5 기본 write.skin.php 파일에

 

라디오 버튼을 이용한 스크립트를 작성하였습니다.

 

352e63ec685f3c5e14eec5b24e8b2fca_1474530789_0392.PNG
352e63ec685f3c5e14eec5b24e8b2fca_1474530789_0877.PNG
 

나름대로 해보려고 작성하였는데 사진처럼 첫화면부터 판매자 구매자가 다 뜨고

 

판매자 라디오 버튼을 눌러도 변동은 없습니다.

 

구매자 라디오 버튼을 누르면

 

판매자와 전화번호가 사라집니다. (이건 제가 원하는것)

 

판매자라디오버튼을 눌렀을때는 판매자만 뜨고(구매자 tr은 사라짐)

 

구매자를 눌렀을땐 구매자만 뜨게 하고 싶습니다.(판매자 tr은 사라짐)

 

당최 해결이 되지 않네요 ㅠㅠ 도움부탁드립니다.

 

 

이 질문에 댓글 쓰기 :

답변 2

Raio_Off

 철자가 틀렸습니다.

tr에다가 하지마시고 div로 감싸세여

 

 


 
<tr>
            <th scope="row"><label for="wr_subject">제목<strong class="sound_only">필수</strong></label></th>
            <td>
                <div id="autosave_wrapper">
                    <input type="text" name="wr_subject" value="<?php echo $subject ?>" id="wr_subject" required class="frm_input required" size="50" maxlength="255">
                    <?php if ($is_member) { // 임시 저장된 글 기능 ?>
                    <script src="<?php echo G5_JS_URL; ?>/autosave.js"></script>
                    <?php if($editor_content_js) echo $editor_content_js; ?>
                    </div>
                    <?php } ?>
                </div>
            </td>
            <th scope="row"><label for="wr_10">구분</label></th>
            <td>
                <input type="radio" name="wr_10" id="wr_10" value="판매자" onclick="RadioChk('Radio_On');"/>판매자
                <input type="radio" name="wr_10" id="wr_10" value="구매자" onclick="RadioChk('Radio_Off');"/>구매자
            </td>
        </tr>
    
        <div id="Radio_On" style="display:block;">
            <th scope="row"><label for="wr_1">판매자</br>(기업/단체)</label></th>
            <td>
                <input type="text" name="wr_1" value="<?=$write['wr_1']?>" size="50" maxlength="255"/>
            </td>
            <th scope="row"><label for="wr_2">전화번호</label></th>
            <td>
                <input type="text" name="wr_2" value="<?=$write['wr_2']?>" size="50" maxlength="255"/>
            </td>
        </div>
 
        <div id="Radio_Off" style="display:block;">
            <th scope="row"><label for="wr_8">구매자</br>(기업/단체)</label></th>
            <td>
                <input type="text" name="wr_8" value="<?=$write['wr_8']?>" size="50" maxlength="255" />
            </td>
            <th scope="row"><label for="wr_2">전화번호</label></th>
            <td>
                <input type="text" name="wr_2" value="<?=$write['wr_2']?>" size="50" maxlength="255"/>
            </td>
            
        </div>
 
        <tr>
            <th scope="row"><label for="wr_3">이메일</label></th>
            <td>
                <input type="text" name="wr_3" value="<?=$write['wr_3']?>" size="50" maxlength="255"/>
            </td>
            <th scope="row"><label for="wr_4">상품</label></th>
            <td>
                <input type="text" name="wr_4" value="<?=$write['wr_4']?>" size="50" maxlength="255"/>
            </td>
        </tr>
 
        <tr>
            <th scope="row"><label for="wr_5">가격</label></th>
            <td>
                <input type="text" name="wr_5" value="<?=$write['wr_5']?>" size="50" maxlength="255"/>
            </td>
            
        </tr>
            
        <tr>
            <th scope="row" ><label for="wr_6">배송방법</label></th>
            <td>
                <input type="text" name="wr_6" value="<?=$write['wr_6']?>" size="50" maxlength="255"/>
            </td>
            <th scope="row"><label for="wr_7">결제방법</label></th>
            <td>
                <input type="text" name="wr_7" value="<?=$write['wr_7']?>" size="50" maxlength="255"/>
            </td>
        </tr>
        
 
        <tr>
            <th scope="row"><label for="wr_content">상품설명<strong class="sound_only">필수</strong></label></th>
           
               </tbody>
        </table>
    </div>
 
<script>
 
function RadioChk(id) {
            if(id=="Radio_On") {

                document.all("Radio_On").style.display = 'block';
                document.all("Radio_Off").style.display = 'none';
            } else {
                document.all("Radio_On").style.display = 'none';
                document.all("Radio_Off").style.display = 'block';
            }
        }
</script>
 

이렇게 하시면 됩니다.

 


<script>
function RadioChk(id)
{
 
   if(id == "Radio_On")
   {
      document.all("Radio_On").style.display = '';         // 보이게
      document.all("Radio_Off").style.display = 'none';  // 안보이게
   }
   else
   {
      document.all("Radio_On").style.display = 'none';  // 안보이게
      document.all("Radio_Off").style.display = '';         // 보이게
   }
}
</script>
 
<form name="fwrite" id="fwrite" action="<?php echo $action_url ?>" onsubmit="return fwrite_submit(this);" method="post" enctype="multipart/form-data" autocomplete="off" style="width:<?php echo $width; ?>">
<div>
	<table>
		<tr>
            <th scope="row"><label for="wr_subject">제목<strong class="sound_only">필수</strong></label></th>
            <td>
                <div id="autosave_wrapper">
                    <input type="text" name="wr_subject" value="<?php echo $subject ?>" id="wr_subject" required class="frm_input required" size="50" maxlength="255">
                    <?php if ($is_member) { // 임시 저장된 글 기능 ?>
                    <script src="<?php echo G5_JS_URL; ?>/autosave.js"></script>
                    <?php if($editor_content_js) echo $editor_content_js; ?>
                    </div>
                    <?php } ?>
                </div>
            </td>
            <th scope="row"><label for="wr_10">구분</label></th>
            <td>
                <input type="radio" name="wr_10" id="wr_10" value="판매자" onclick="RadioChk('Radio_On');"/>판매자
                <input type="radio" name="wr_10" id="wr_10" value="구매자" onclick="RadioChk('Radio_Off');"/>구매자
            </td>
        </tr>
    
        <tr id="Radio_On" style="display:none;"> 
            <th scope="row"><label for="wr_1">판매자</br>(기업/단체)</label></th>
            <td>
                <input type="text" name="wr_1" value="<?=$write['wr_1']?>" size="50" maxlength="255"/>
            </td>
            <th scope="row"><label for="wr_2">전화번호</label></th>
            <td>
                <input type="text" name="wr_2" value="<?=$write['wr_2']?>" size="50" maxlength="255"/>
            </td>
        </tr>
 
        <tr id="Radio_Off" style="display:none;">
            <th scope="row"><label for="wr_8">구매자</br>(기업/단체)</label></th>
            <td>
                <input type="text" name="wr_8" value="<?=$write['wr_8']?>" size="50" maxlength="255" />
            </td>
            <th scope="row"><label for="wr_2">전화번호</label></th>
            <td>
                <input type="text" name="wr_2" value="<?=$write['wr_2']?>" size="50" maxlength="255"/>
            </td>
            
        </tr>
 
        <tr>
            <th scope="row"><label for="wr_3">이메일</label></th>
            <td>
                <input type="text" name="wr_3" value="<?=$write['wr_3']?>" size="50" maxlength="255"/>
            </td>
            <th scope="row"><label for="wr_4">상품</label></th>
            <td>
                <input type="text" name="wr_4" value="<?=$write['wr_4']?>" size="50" maxlength="255"/>
            </td>
        </tr>
 
        <tr>
            <th scope="row"><label for="wr_5">가격</label></th>
            <td>
                <input type="text" name="wr_5" value="<?=$write['wr_5']?>" size="50" maxlength="255"/>
            </td>
            
        </tr>
            
        <tr>
            <th scope="row" ><label for="wr_6">배송방법</label></th>
            <td>
                <input type="text" name="wr_6" value="<?=$write['wr_6']?>" size="50" maxlength="255"/>
            </td>
            <th scope="row"><label for="wr_7">결제방법</label></th>
            <td>
                <input type="text" name="wr_7" value="<?=$write['wr_7']?>" size="50" maxlength="255"/>
            </td>
        </tr>
        
 
        <tr>
            <th scope="row"><label for="wr_content">상품설명<strong class="sound_only">필수</strong></label></th>
           
               </tbody>
 
	</table>
</div>
 
</form>
답변을 작성하시기 전에 로그인 해주세요.
전체 3

회원로그인

(주)에스아이알소프트 / 대표:홍석명 / (06211) 서울특별시 강남구 역삼동 707-34 한신인터밸리24 서관 1402호 / E-Mail: admin@sir.kr
사업자등록번호: 217-81-36347 / 통신판매업신고번호:2014-서울강남-02098호 / 개인정보보호책임자:김민섭(minsup@sir.kr)
© SIRSOFT