팝업창 오류
본문
그누보드4 팝업 사용하고 있는 소스주소입니다
https://sir.kr/g4_plugin/12693?sfl=wr_subject&stx=%ED%8C%9D%EC%97%85
선택수정버튼과 선택삭제버튼이 먹통입니다
다음 소스중 어디를 수정해야 할까요?
-------------------------------------------------------------------------------------------------------------------
<?
$sub_menu = "300600";
include_once("./_common.php");
auth_check($auth[$sub_menu], "r");
if ($is_admin != "super")
alert("최고관리자만 접근 가능합니다.");
$g4['title'] = "레이어팝업 관리";
include_once ("./admin.head.php");
if ($w == "선택수정")
{
for($i=0;$i<count($chk);$i++){
$sql = " update $g4[layer_popup_table] set lp_type = '{$lp_type[$chk[$i]]}', lp_use = '{$lp_use[$chk[$i]]}' where lp_id = {$lp_id[$chk[$i]]} ";
sql_query($sql);
}
}
else if ($w == "선택삭제")
{
for($i=0;$i<count($chk);$i++){
$sql = " delete from $g4[layer_popup_table] where lp_id = {$lp_id[$chk[$i]]} ";
//die($sql);
sql_query($sql);
}
}
$colspan=9;
$sql = "select * from $g4[layer_popup_table] order by lp_id desc ";
$result = sql_query($sql, false);
// 테이블이 없다면 생성합니다.
if (!$result)
{
sql_query(" CREATE TABLE IF NOT EXISTS `$g4[layer_popup_table]` (
`lp_id` int(11) NOT NULL auto_increment,
`lp_type` varchar(255) NOT NULL,
`lp_gigan` tinyint(4) NOT NULL,
`lp_begin_datetime` datetime NOT NULL,
`lp_end_datetime` datetime NOT NULL,
`lp_subject` varchar(255) NOT NULL,
`lp_left` int(11) NOT NULL,
`lp_top` int(11) NOT NULL,
`lp_width` int(11) NOT NULL,
`lp_height` int(11) NOT NULL,
`lp_center` tinyint(4) NOT NULL,
`lp_menubar` tinyint(4) NOT NULL,
`lp_toolbar` tinyint(4) NOT NULL,
`lp_resizable` tinyint(4) NOT NULL,
`lp_scrollbars` tinyint(4) NOT NULL,
`lp_status` tinyint(4) NOT NULL,
`lp_content` text NOT NULL,
`lp_use` tinyint(4) NOT NULL,
PRIMARY KEY (`lp_id`)
) ");
}
$total_count = @mysql_num_rows($result);
$rows = $config[cf_page_rows];
$total_page = ceil($total_count / $rows); // 전체 페이지 계산
if (!$page) $page = 1; // 페이지가 없으면 첫 페이지 (1 페이지)
$from_record = ($page - 1) * $rows; // 시작 열을 구함
$sql="select * from $g4[layer_popup_table] order by lp_id desc limit $from_record, $rows ";
$result = sql_query($sql);
?>
<style>
form { margin:0px; padding:0px; }
.datetime { font:11px tahoma; }
</style>
<form id=fsearch>
<input type=hidden name=page value="<?=$page?>">
<table width=100% cellpadding=4 cellspacing=0>
<tr>
<td width=20%><a href="<?=$_SERVER[PHP_SELF]?>">처음</a></td>
<td width=60% align=center>
</td>
<td width=20% align=right>건수 : <? echo $total_count ?> </td>
</tr>
</table>
</form>
<table width=100% cellpadding=0 cellspacing=1>
<form id=flist method=post action="<?=$_SERVER[PHP_SELF]?>">
<input type=hidden name=page value="<?=$page?>">
<input type=hidden name=w value="">
<colgroup width=30>
<colgroup width=>
<colgroup width=60>
<colgroup width=60>
<colgroup width=60>
<colgroup width=60>
<colgroup width=70>
<colgroup width=40>
<colgroup width=30>
<tr><td colspan='<?=$colspan?>' class='line1'></td></tr>
<tr class='bgcol1 bold col1 ht center'>
<td><input type="checkbox" id="allchk"></td>
<td>제목</td>
<td>타입</td>
<td>사이즈</td>
<td>기간</td>
<td>시작날짜</td>
<td>마지막날짜</td>
<td>사용</td>
<td><a href="./layer_form.php"><img src='<?=$g4[admin_path]?>/img/icon_insert.gif' border=0 title='팝업생성'></a></td>
</tr>
<?
for($i=0;$row=sql_fetch_array($result);$i++)
{
$subject = stripslashes($row[lp_subject]);
$gigan = $row[lp_gigan]."일";
?>
<tr class='list$list col2 ht center'>
<td>
<input type=checkbox name="chk[]" value="<?=$i?>">
<input type=hidden name='lp_id[]' value='<?=$row[lp_id]?>'>
</td>
<td align=left><?=$subject?></td>
<td>
<select name="lp_type[]" id="lp_type_<?=$i?>">
<option value="레이어">레이어</option>
<option value="팝업창">팝업창</option>
</select>
<script>document.getElementById("lp_type_<?=$i?>").value = "<?=$row[lp_type]?>";</script>
</td>
<td><?=$row[lp_width]?>x<?=$row[lp_height]?></td>
<td><?=$gigan?></td>
<td class=datetime><?=substr($row[lp_begin_datetime],2,11)?></td>
<td class=datetime><?=substr($row[lp_end_datetime],2,11)?></td>
<td>
<select name="lp_use[]" id="lp_use_<?=$i?>">
<option value="1">사용</option>
<option value="0">일시중지</option>
</select>
<script>document.getElementById("lp_use_<?=$i?>").value = "<?=$row[lp_use]?>";</script>
</td>
<td align=center>
<a href="./layer_form.php?w=u&lp_id=<?=$row[lp_id]?>"><img src='img/icon_modify.gif' border=0 title='수정'></a>
</td>
</tr>
<tr><td colspan='<?=$colspan?>' class='line2'></td></tr>
<?}?>
<?if(!$total_count){?>
<tr><td colspan='<?=$colspan?>' align=center height=100 bgcolor=#ffffff>팝업이 생성되지 않았습니다.</td></tr>
<tr><td colspan='<?=$colspan?>' class='line2'></td></tr>
<?}?>
</table>
<table width=100% cellpadding=3 cellspacing=1>
<tr><td width=70%>
<input type=button class="btn1" id="chkupd" value="선택수정">
<input type=button class="btn1" id="chkdel" value="선택삭제">
</td>
<td width=30% align=right><?=get_paging($config[cf_write_pages], $page, $total_page, "$_SERVER[PHP_SELF]?$qstr&page=")?></td>
</tr></table>
</form>
<script type="text/javascript">
$(function() {
$("#allchk").bind("click", function() {
$("[name=chk\[\]]").attr("checked", this.checked);
});
$("#chkupd,#chkdel").bind("click", function() {
if (!$("[name=chk\[\]]:checked").length)
{
alert(this.value+"하실 항목을 선택하세요.");
return;
}
// 선택삭제의 경우에만 물어봄
if (this.id == "chkdel" && !confirm(this.value+" 후에는 복구가 불가합니다.\n\n정말 실행하시겠습니까?"))
return;
$("#flist [name=w]").val(this.value);
$("#flist").submit();
});
});
</script>
<?
include_once("./admin.tail.php");
?>
-------------------------------------------------------------------------------------------------------------
리스트에서 수정 안되는 현상 수정
$("#flist [name=w]").val(this.value);
에서
$("input[name=w]").val(this.value);
로 수정
사유. name=w 값에 벨류값이 정상적으로 지급 안됨
해결
다이렉트로 input의 name이 w인것을 찾아 지정한다.
-------------------------------------------------------------------------------------------------------------
윗글 처럼 하라는데 수정해도 선택수정버튼과 선택삭제버튼이 그대로 먹통입니다
답변 1
버튼 이벤트에는 문제가 없습니다. 혹시 리스트 선택시 오류가 있는지 확인해보시기 바랍니다
혹시 몰라 제가 사용하는 그누4 팝업 기능 공유해드리니 참고 바랍니다.
<?
$sub_menu = "300900";
include_once("./_common.php");
auth_check($auth[$sub_menu], "r");
$sql_common = " from g4_popup ";
$sql_search = " where (1) ";
if ($stx) {
$sql_search .= " and ( ";
switch ($sfl) {
case "mb_id" :
$sql_search .= " ($sfl = '$stx') ";
break;
default :
$sql_search .= " ($sfl like '%$stx%') ";
break;
}
$sql_search .= " ) ";
}
if (!$sst) {
$sst = "pop_id";
$sod = "desc";
}
$sql_order = " order by $sst $sod ";
$sql = " select count(*) as cnt
$sql_common
$sql_search
$sql_order ";
$row = sql_fetch($sql);
$total_count = $row[cnt];
$rows = $config[cf_page_rows];
$total_page = ceil($total_count / $rows); // 전체 페이지 계산
if ($page == "") $page = 1; // 페이지가 없으면 첫 페이지 (1 페이지)
$from_record = ($page - 1) * $rows; // 시작 열을 구함
$sql = " select *
$sql_common
$sql_search
$sql_order
limit $from_record, $rows ";
$result = sql_query($sql);
$listall = "<a href='$_SERVER[PHP_SELF]'>처음</a>";
if ($sfl == "mb_id" && $stx)
$mb = get_member($stx);
$g4[title] = "팝업관리";
include_once ("./admin.head.php");
$colspan = 8;
?>
<script language="JavaScript">
var list_update_php = "popup_update.php";
var list_delete_php = "popup_delete.php";
</script>
<form name=fpopuplist method=post>
<table width="800" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td align="center">
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr><td height="5"></td></tr>
<tr><td height="24"><span class="redb_txt"><?=$g4[title]?></span></td></tr>
<tr><td height="5" bgcolor="#999999"></td></tr>
</table>
<table width="100%" border="1" align="center" cellpadding="0" cellspacing="0" bordercolorlight="#E1E1E1" bordercolordark="white">
<input name="page" type="hidden" value="<?=$page?>">
<input type=hidden name=act value="multi">
<tr class='bgcol1 bold col1 ht center'>
<td width="25"><input type=checkbox name=chkall value='1' onclick='check_all(this.form)'></td>
<td width="280">타이틀</td>
<td width="30">사용</td>
<td width="80">시작날짜</td>
<td width="80">마감날짜</td>
<td width="130">작성일</td>
<td><a href="./popup_edit.php"><img src='<?=$g4[admin_path]?>/img/icon_insert.gif' border=0 title='생성'></a></td>
</tr>
<?
for ($i=0; $row=sql_fetch_array($result); $i++)
{
$s_upd = "<a href='./popup_edit.php?mode=edit&pop_id=$row[pop_id]'><img src='img/icon_modify.gif' border=0 title='수정'></a>";
$s_del = "<a href=\"javascript:del('./popup_delete.php?mode=delete&pop_id=$row[pop_id]');\"><img src='img/icon_delete.gif' border=0 title='삭제'></a>";
$list = $i%2;
echo "
<input type=hidden name=pop_id[$i] value='$row[pop_id]'>
<tr class='list$list col1 ht center'>
<td><input type=checkbox name=chk[] value='$i'></td>
<td><a href='popup_edit.php?mode=edit&pop_id=$row[pop_id]'>$row[pop_title]</a></td>
<td><input type=checkbox name=pop_use[$i] ".($row[pop_use]?'checked':'')." value='1'></td>
<td>$row[start_date]</td>
<td>$row[end_date]</td>
<td>$row[create_date]</td>
<td>$s_upd $s_del</td>
</tr> ";
}
if ($i == 0)
echo "<tr><td colspan='$colspan' align=center height=100 bgcolor=#ffffff>자료가 없습니다.</td></tr>";
echo "<tr><td colspan='$colspan' class='line2'></td></tr>";
echo "</table>";
$pagelist = get_paging($config[cf_write_pages], $page, $total_page, "$_SERVER[PHP_SELF]?$qstr&page=");
echo "<table width=100% cellpadding=3 cellspacing=1>";
echo "<tr><td width=50%>";
echo "<input type=button class='btn1' value='선택수정' onclick=\"btn_check(this.form, 'update')\"> ";
echo "<input type=button class='btn1' value='선택삭제' onclick=\"btn_check(this.form, 'delete')\">";
echo "</td>";
echo "<td width=50% align=right>$pagelist</td></tr></table>\n";
?>
</form>
<?
include_once ("./admin.tail.php");
?>