채택완료

if문 문의드립니다.

버튼1 | 버튼2 | 버튼3 | 버튼4

<?php echo latest('SKINNAME','$TableName',10,0);?>

 

클릭하는 버튼에 따라서 불러오는 게시판을 바꿀 수 있을까요?

 

$TableName = $button_id

|

답변 5개 / 댓글 5개

채택된 답변
+20 포인트

<button type="button" onclick="ajax_latest('button_id1')">버튼1</button>
<button type="button" onclick="ajax_latest('button_id2')">버튼2</button>
<button type="button" onclick="ajax_latest('button_id3')">버튼3</button>
<button type="button" onclick="ajax_latest('button_id4')">버튼4</button>
<div id="blatest">
</div>

<script type="text/javascript">
<!--
functon ajax_latest(tableName){

    $.ajax({
        type: "GET",
        url: g5_url +"/ajax_latest.php",
        data:{"bo_table":"tableName"} ,
        success: function(data) {
            jQuery("#blatest").html(data);
        }
    });    
}
//-->
</script>

....
ajax_latest.php (그누보드 루트에)
<?php 
include_once('./_common.php');
echo latest('SKINNAME', $bo_table, 6, 24);
?>

답변에 대한 댓글 2개

답변감사합니다.
근데 ajax_latest.php를 못불러오네요...
어떤문제인지 모르겠습니다.
Uncaught ReferenceError: ajax_latest is not defined
at HTMLButtonElement.onclick
죄송합니다 함수가 function 인데 functon 으로 되어있네요.
아래로 사용하시면 됩니다

function ajax_latest(tableName){

$.ajax({
type: "GET",
url: g5_url +"/ajax_latest.php",
data:{"bo_table":tableName} ,
success: function(data) {
jQuery("#blatest").html(data);
}
});
}

JS로 구현하셔서 클릭시 특정탭이 active (active 제외 display:none) 되게 하시면 됩니다.

ajax로 처리하셔도 되고요.

아니면 해당 페이지 처음부분에 자바스크립트로 해당 동작 하게 구현한뒤에

form submit해서 같은 페이지를 새로 로드해서 처리하는 방식도 가능합니다.

답변에 대한 댓글 1개

해당 부분은 onlymilk47님 처럼 ajax로 처리하셔야 할듯 합니다.

답변에 대한 댓글 1개

 if문보다는 그냥 퍼블리싱으로 처리하셔도될거같은데요

 

탭안에 불러올 최신글만 처리한다면..

답변에 대한 댓글 1개

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