자식창에서 검색값을 부모창으로 넘기는 질문
본문
어렵지 않은 부분에서 어의없게 해매고 있네요;;;;;ㅠㅠ
부모창의 input을 클릭했을때 자식창 popup이 뜨고 거기서 검색을 해서
검색결과를 클릭했을때 부모창의 input에 값이 들어가면 되는 부분인데요;;;
일단 부모창의 input은 id="etc_4" onclick="window.open('works/test.php','asf','width=400,height=600');
요렇게 해서 자식창을 띄웁니다.
자식창은
<?
$root = "../";
include "{$root}db.inc.php";
include "{$root}config.inc.php";
?>
<form name="aaa">
<input type="text" name="etc_4_sch">
<input type="submit">
<?
if($_GET[etc_4_sch]){
$etc_sel = "select subject from 테이블 where subject like '%{$_GET[etc_4_sch]}%' group by subject order by subject asc";
//echo $etc_sel;
$result = mysql_query($etc_sel);
while($row=mysql_fetch_array($result)) {
?>
<a onclick="opener.document.TCBOARD_BD47410_WRITE_index1.getElementById('etc_4').value=<?=$row[subject];?>;window.close();"><?=$row[subject];?></a>
<?
}
}
?>
</form>
요렇게 되어있구요;;;
결과에 onclick을 걸었는데 클릭하면
Uncaught TypeError: opener.document.TCBOARD_BD47410_WRITE_index1.getElementById is not a function at HTMLAnchorElement.onclick (test.php?etc_4_sch=불광:5)
이런 에러가 뜹니다...검색어는 '불광'입니다.
이유가 뭘까요?
!-->
답변 2
<a onclick="opener.document.getElementById('etc_4').value='<?=$row[subject];?>';window.close();"><?=$row[subject];?></a>
부모창 form 이름이 TCBOARD_BD47410_WRITE_index1 인가요?
답변을 작성하시기 전에 로그인 해주세요.