테스트 사이트 - 개발 중인 베타 버전입니다

게시판 글쓰기시 카테고리에 따라 나오는 항목을 다르게 할 수 있을까요? 채택완료

몰라용 7년 전 조회 3,360

그누보드 5.3으로 예약게시판을 만드는 중입니다.

A, B, C 각각 다른 게시판에서 게시물(상품) 선택 후 예약하기 버튼을 누르면 D게시판에서 통합되어 예약폼을 입력하게 하고 있습니다.

 

일단, A, B, C 게시판명으로 D에서 자동으로 카테고리로 되게는 했는데, 예약폼 입력시 A, B, C중 한 게시판에 대해서만 입력폼 내용이 하나 더 추가되어야 해서 문의 드립니다.

 

D게시판 입력폼이 대략 아래와 같습니다.

 

카테고리명 : 자동입력 상품명 : 자동입력

 

직접입력 항목 항목1 :  항목2 :  항목3 :

이라고 할적에

만약 카테고리명이 A, B일 때는 항목3 : 이 나오고,

카테고리명이 C일 때는 항목 3 : 항목 4 : 가 나오게 하는 방법이 있을까요?

 

혹시 아시는분 계시면 답변 좀 부탁드립니다.

감사합니다.

댓글을 작성하려면 로그인이 필요합니다.

답변 2개

채택된 답변
+20 포인트
S
7년 전

주석문 부분 확인하시면 이해가 가실꺼에요

</p>

<p><? if($w == 'u') { ?> 

            <tr> 

                <th class='th1'>카테고리</td> 

                <td class='td5'><input type="text" name="ca_name" value="<?php echo $ca_name ?>" id="ca_name" class="full_input" required style="border-style:none;" maxlength="255" readonly placeholder="카테고리"></td> 

            </tr> 

            <? } else { ?> 

            <tr> 

                <th class='th1'>카테고리</td> 

                <td class='td5'><input type="text" name="ca_name" value="<?=$s2?>" id="ca_name" class="full_input" required style="border-style:none;" readonly maxlength="255"></td> 

            </tr> 

            <? } ?> </p>

<p>            <? if($w == 'u') { ?> 

            <tr> 

                <th class='th1'>상 품 명</td> 

                <td class='td5'><input type="text" name="wr_subject" value="<?php echo $subject ?>" id="wr_subject" class="full_input" required style="border-style:none;" maxlength="255" readonly placeholder="상 품 명"></td> 

            </tr> 

            <? } else { ?> 

            <tr> 

                <th class='th1'>상 품 명</td> 

                <td class='td5'><input type="text" name="wr_subject" value="<?=$s1?>" id="wr_subject" class="full_input" required style="border-style:none;" readonly maxlength="255"></td> 

            </tr> 

            <? } ?> </p>

<p>            <!-- 입력폼 : s1이 A이거나 B일떄  / 수정폼 : ca_name이 A이거나 B일댸 -->

            <?php if($s1 == "A" || $s1 == "B" || $ca_name == "A" || $ca_name == "B"){?>

            <tr> 

                <th class='th1'>항목1</td> 

                <td class='td5'><input type="text" name="wr_1_1" value="<?php echo $wr_1_1 ?>" id="wr_1_1" class="frm_input required" maxlength="255" placeholder="항목1"></td> 

            </tr> 

            <tr> 

                <th class='th1'>항목2</td> 

                <td class='td5'><input type="text" name="wr_1_2" value="<?php echo $wr_1_2 ?>" id="wr_1_2" class="frm_input required" maxlength="255" placeholder="항목2"></td> 

            </tr> 

            <tr> 

                <th class='th1'>항목3</td> 

                <td class='td5'><input type="text" name="wr_1_3" value="<?php echo $wr_1_3 ?>" id="wr_1_3" class="frm_input required" maxlength="255" placeholder="항목3"></td> 

            </tr> 

            <?php }?></p>

<p>            <!-- 입력폼 : s1이 C일떄  /  수정폼 : ca_name이 C일댸 -->

            <?php if($s1 == "C" || $ca_name == "C"){?>

            <tr> 

                <th class='th1'>항목1</td> 

                <td class='td5'><input type="text" name="wr_1_1" value="<?php echo $wr_1_1 ?>" id="wr_1_1" class="frm_input required" maxlength="255" placeholder="항목1"></td> 

            </tr> 

            <tr> 

                <th class='th1'>항목2</td> 

                <td class='td5'><input type="text" name="wr_1_2" value="<?php echo $wr_1_2 ?>" id="wr_1_2" class="frm_input required" maxlength="255" placeholder="항목2"></td> 

            </tr> 

            <tr> 

                <th class='th1'>항목3</td> 

                <td class='td5'><input type="text" name="wr_1_3" value="<?php echo $wr_1_3 ?>" id="wr_1_3" class="frm_input required" maxlength="255" placeholder="항목3"></td> 

            </tr> 

            <tr> 

                <th class='th1'>항목4</td> 

                <td class='td5'><input type="text" name="wr_1_4" value="<?php echo $wr_1_4 ?>" id="wr_1_4" class="frm_input required" maxlength="255" placeholder="항목4"></td> 

            </tr>

            <?php }?></p>

<p>

로그인 후 평가할 수 있습니다

답변에 대한 댓글 1개

몰라용
7년 전
정말 정말 감사합니다.
덕분에 해결하였습니다.
다시한번 감사드립니다.

댓글을 작성하려면 로그인이 필요합니다.

S
7년 전

카테고리명 value값을 이용해서 스크립트로 처리가 가능할꺼 같은데요..

 

[ex]

</p>

<p><script type="text/javascript">

<!--

    $(function(){</p>

<p>        var category = $("카테고리").val();</p>

<p>        if(category == "C"){

            $("항목1").hide();

            $("항목2").hide();

            $("항목3").show();

            $("항목4").show();

        }else{

            $("항목1").hide();

            $("항목2").hide();

            $("항목3").show();

            $("항목4").hide();

        }</p>

<p>

     });

//-->

</script></p>

<p>

로그인 후 평가할 수 있습니다

답변에 대한 댓글 3개

몰라용
7년 전
친절하신 답변 감사합니다.
그런데 제가 실력이 미천한지라 저 스크립트를 이용해서,
항목에 어떻게 추가를 해야 할지를 모르겠네요.
로토루아
7년 전
D게시판 입력폼 내용을 올려줘 보세요.
좀더 자세히 설명드릴께요.
몰라용
7년 전
네 입력폼은 아래와 같습니다.

<? if($w == 'u') { ?>
<tr>
<th class='th1'>카테고리</td>
<td class='td5'><input type="text" name="ca_name" value="<?php echo $ca_name ?>" id="ca_name" class="full_input" required style="border-style:none;" maxlength="255" readonly placeholder="카테고리"></td>
</tr>
<? } else { ?>
<tr>
<th class='th1'>카테고리</td>
<td class='td5'><input type="text" name="ca_name" value="<?=$s2?>" id="ca_name" class="full_input" required style="border-style:none;" readonly maxlength="255"></td>
</tr>
<? } ?>

<? if($w == 'u') { ?>
<tr>
<th class='th1'>상 품 명</td>
<td class='td5'><input type="text" name="wr_subject" value="<?php echo $subject ?>" id="wr_subject" class="full_input" required style="border-style:none;" maxlength="255" readonly placeholder="상 품 명"></td>
</tr>
<? } else { ?>
<tr>
<th class='th1'>상 품 명</td>
<td class='td5'><input type="text" name="wr_subject" value="<?=$s1?>" id="wr_subject" class="full_input" required style="border-style:none;" readonly maxlength="255"></td>
</tr>
<? } ?>


<tr>
<th class='th1'>항목1</td>
<td class='td5'><input type="text" name="wr_1_1" value="<?php echo $wr_1_1 ?>" id="wr_1_1" class="frm_input required" maxlength="255" placeholder="항목1"></td>
</tr>
<tr>
<th class='th1'>항목2</td>
<td class='td5'><input type="text" name="wr_1_2" value="<?php echo $wr_1_2 ?>" id="wr_1_2" class="frm_input required" maxlength="255" placeholder="항목2"></td>
</tr>
<tr>
<th class='th1'>항목3</td>
<td class='td5'><input type="text" name="wr_1_3" value="<?php echo $wr_1_3 ?>" id="wr_1_3" class="frm_input required" maxlength="255" placeholder="항목3"></td>
</tr>


카테고리와 상품명은 이미 A, B, C 게시판에서 선택한 상품으로 자동으로 입력이 되어 있는 상태입니다.
카테고리는 A, B, C 게시판명이 되게 했구요.

그 아래 항목1, 항목2, 항목3은 직접 입력하게 되는 부분인데,
카테고리명이 A, B일때는 항목1, 항목2, 항목3이 보여지고,
C일때는 항목1, 항목2, 항목3, 항목4가 보여지게 하고 싶습니다.

댓글을 작성하려면 로그인이 필요합니다.

답변을 작성하려면 로그인이 필요합니다.

로그인