it_id 값에 따라 다른 링크로 가게 하려는데 안되네요 채택완료
<script>
<?php
function sub() {
if ($it['it_id'] === '1658321866') {
goto_url("https://주소/shop/item.php?it_id=1659417115");
}
else if ($it['it_id'] === '1658321766') {
goto_url("https://주소/shop/item.php?it_id=1659417115");
}
};
?>
</script>
<button type='button' id="write" onclick="sub"> 작성하기 </button>
item.form.skin.php에 만들었는데 버튼을 클릭해도 반응이 없습니다.
상품상세보기 안에서 다른 상품상세보기로 넘어가는 기능을 만들고 있습니다.
답변 2개
펑션은 php 인데 스크립트로 둘러싸셨네요. 저러면 안됩니다.
<script>
var it_id = '<?php echo $it['it_id']?>';
function sub() {
if(it_id=='1658321866') {
location.href='https://주소/shop/item.php?it_id=1659417115';
} else if(it_id=='1658321766') {
location.href='https://주소/shop/item.php?it_id=1659417115';
}
}
</script>
<button type='button' id="write" onclick="sub()"> 작성하기 </button>
답변에 대한 댓글 1개
댓글을 작성하려면 로그인이 필요합니다.
답변을 작성하려면 로그인이 필요합니다.
로그인