너무 막혀서 질문드립니다.

<SCRIPT LANGUAGE='JavaScript'>
// 이미지뷰어
<!--
var win= null;
function View_Open(img, w, h)
{
var winl = (screen.width-w)/2;
var wint = (screen.height-h)/3;
var settings ='height='+h+',';
settings +='width='+w+',';
settings +='top='+wint+',';
settings +='left='+winl+',';
settings +='scrollbars=yes,';
settings +='resizable=yes,';
settings +='status=no';

win=window.open("","newWindow",settings);
win.document.open();
win.document.write ("<html><head><title>Detail Zoom</title></head>");
win.document.write ("<script>function init(){window.resizeBy(document.all.pop_img.width-document.body.clientWidth, document.all.pop_img.height-document.body.clientHeight+10);}</script>");
win.document.write ("<body bgcolor=white topmargin=0 leftmargin=0 marginwidth=0 marginheight=0 oncontextmenu='return false' ondragstart='return false' onkeydown='return false' onselectstart='return false' onload='init();'>");
win.document.write ("<img src='"+img+"' border=0 onclick='window.close();' style='cursor:hand' title='닫기' id='pop_img'>");
win.document.write ("</body></html>");
win.document.close();
}
//-->
</SCRIPT>

<SCRIPT LANGUAGE="JavaScript">
<!--
clear = new Image();
<?
//파일 뽑기
$sql2 = " select bf_file from $g4[board_file_table] where bo_table = '$bo_table' and wr_id = '$wr_id' order by bf_no limit 0, 10 ";
$result2 = sql_query($sql2);
for ($j=0; $row2 = sql_fetch_array($result2); $j++) {

if($j==0) {
$view_one = "{$g4['path']}/data/file/{$bo_table}/{$row2['bf_file']}";
}

?>
view_img<?=$j?> = new Image();
view_img<?=$j?>.src = "<?=$g4['path']?>/data/file/<?=$bo_table?>/<?=$row2['bf_file']?>";
<? } ?>
function bgChange(imgName) {
document.all.view_img.src = eval(imgName + ".src");
}
// -->
</SCRIPT>

<div>
<a href="javascript:void(0);" onClick="View_Open('<?=$view_one?>')"><img src="<?=$view_one?>" name="view_img" width=440 height=600></a>
</div>

<div>
<?
//파일 뽑기
$sql = " select bf_file from $g4[board_file_table] where bo_table = '$bo_table' and wr_id = '$wr_id' order by bf_no limit 0, 10 ";
$result = sql_query($sql);
for ($i=0; $row = sql_fetch_array($result); $i++) {

//썸네일 코드 시작
$data_path = $g4['path'] . "/data/file/{$bo_table}";//라이브러리 파일 참조
$thumb_path = $data_path . '/thumbOpen';

$view_w = 80; //썸네일 가로사이즈
$view_h = 109; //썸네일 세로사이즈
$sch_q = 99; //썸네일 퀼리티

if (!is_dir($thumb_path)) {
@mkdir($thumb_path, 0707);
@chmod($thumb_path, 0707);
}
$filename = $row[bf_file]; //파일명
$thumb = $thumb_path.'/'.$filename; //썸네일
if (!file_exists($thumb))
{
$file = $data_path.'/'.$filename; //원본
if (preg_match("/\.(jp[e]?g|gif|png)$/i", $file) && file_exists($file))
{
$size = getimagesize($file);
if ($size[2] == 1)
$src = imagecreatefromgif($file);
else if ($size[2] == 2)
$src = imagecreatefromjpeg($file);
else if ($size[2] == 3)
$src = imagecreatefrompng($file);
else
continue;

$rate = $view_w / $size[0];
$height = (int)($size[1] * $rate);

if ($height < $view_h)
$dst = imagecreatetruecolor($view_w, $height);
else
$dst = imagecreatetruecolor($view_w, $view_h);
imagecopyresampled($dst, $src, 0, 0, 0, 0, $view_w, $height, $size[0], $size[1]);
imagejpeg($dst, $thumb_path.'/'.$filename, $sch_q);
chmod($thumb_path.'/'.$filename, 0707);
}
}

if (file_exists($thumb) && $filename) {
?>
<a href="javascript:void(0);" onClick="bgChange('view_img<?=$i?>');"><img src='<?=$thumb?>' style='margin-right:5px;' border=0></a><?
}
}
?>
</div>




간단한 상품소개 게시판입니다.
스크립트가 오픈창과 사진체인지 두가지가 있습니다.

우선 view화면으로 들어가면
윗부분에 1번사진이 들어가고,
아랫부분에는 1번부터 순차적으로 작은사진들로 썸네일이 구성됩니다.

썸네일로 구성된 사진들을 클릭하면
윗부분의 사진이 클릭된 사진으로 체인지되는데.
큰사진을 클릭하게 되면 원본크기의 사진이 오픈창으로 열리게되있습니다.

문제는 아래의 썸네일사진을 누르면 큰사진으로 바뀌기는 하는데,
큰사진을 클릭해도 1번 사진만 오픈창으로 떠집니다.

썸네일을 클릭해서 바껴진 사진으로 오픈창으로 보고싶습니다. 도와주세요 ㅠ
|

댓글 3개

view_one 자체가 중복문이 아닌 단일이기 때문에 그런건 아닐까요
간단합니다
썸네일 클릭해서 바뀐 이미지를 팝업창 이미지 소스로 만들어주는 부분을 코딩만하면 됩니다
function View_Open(img, w, h)
{
img= document.getElementsByName('view_img')[0].src; //---요것만 추가해주면 됩니다
사랑합니다.
댓글을 작성하시려면 로그인이 필요합니다.

그누4 질문답변

그누보드4 관련 질문은 QA 로 이전됩니다. QA 그누보드4 바로가기 기존 게시물은 열람만 가능합니다.

+
제목 글쓴이 날짜 조회
12년 전 조회 1,531
12년 전 조회 1,540
12년 전 조회 861
12년 전 조회 953
12년 전 조회 884
12년 전 조회 981
12년 전 조회 1,553
12년 전 조회 2,007
12년 전 조회 741
12년 전 조회 909
12년 전 조회 3,776
12년 전 조회 834
12년 전 조회 794
12년 전 조회 831
12년 전 조회 1,513
12년 전 조회 850
12년 전 조회 2,918
12년 전 조회 1,846
12년 전 조회 1,168
12년 전 조회 658