질문하나 드려도될랑가요? 정보
질문하나 드려도될랑가요?
본문
우선 질문은 DB연동 동적 다중셀렉트입니다.
우선 fsec_sel에서 모델msec_sel로 연동되고 sel로 연동도 잘됩니다.
중간에 3가지정도의 비연동 고정형 셀렉트메뉴를 변수로 끼워넣고싶은데
잘 되지가 않습니다.ㅠㅠ
원하는건 바뀌는건 최종 기종선택부분만 바뀌도록하고 나머지메뉴에서 고를때
변수로 검색한값(ex2.php)만 출력되게 하는겁니다만.....
쿼리는 잘 짠거같은데 스크립트는 영 잼병이라 안되네요 ㅠㅠ
msec만 변하고 ex2에 변수 3개를 넘기기만 하면됩니다
가르침을 주시면 오늘 밤샘은 안해도될꺼같습니다.
구동은 링크를 참고해주세요 ㅠ
ps. 추가질문인데 다중선택값까진 표시가 되는데 이걸 실시간으로 처리해서 고를때마다 이미지를 표시하려고하는데 참고할만한 소스나 문서, 혹은 조언도 부탁드립니다 __)
////표시페이지///
<?
$g4_path = ".."; // common.php 의 상대 경로
include_once("$g4_path/common.php");
include_once("$g4[path]/config.php");
include_once("$g4[path]/lib/latest.lib.php");
include_once("$g4[path]/head.sub.php");
include_once("$g4[path]/lib/outlogin.lib.php");
include_once("$g4[path]/lib/poll.lib.php");
include_once("$g4[path]/lib/visit.lib.php");
include_once("$g4[path]/lib/connect.lib.php");
include_once("$g4[path]/lib/popular.lib.php");
?>
<script>
function loaddata(fsec) {
//onChange 된 값을 iframe으로 넘기는 부분
get_msec.location.href='ex2.php?fsec='+fsec;
}
// iframe resize
function autoResize(i)
{
var iframeHeight=
(i).contentWindow.document.body.scrollHeight;
(i).height=iframeHeight+20;
}
</script>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<head>
<link rel='stylesheet' type='text/css' media='all' href='style.css' />
<!-- 파비콘~~ -->
<link rel="SHORTCUT ICON" href="favicon.ico">
</head>
<table border="0" align='center' width='100%'>
<tr><td width='60%'>
<table border="0" align='center' width='900px'>
<tr><td colspan="5" align='center'>
<?
include_once("$g4[path]/head.php");
?>
</td></tr>
<tr><td>
<?
include_once("$g4[path]/menu.php");
?>
</td>
</tr>
<tr>
<td height="10px">
</td>
</tr>
<tr>
<td valign="top">
<form name='item_reg' method = "post" action = "index.php">
<select name='fsec_sel'>
<option value=''>메이커 선택</option>
<?
$maker_query = sql_query("select bo_table, bo_category_list from g4_board where bo_table = 'bike_search' limit 1");
$maker = sql_fetch_array($maker_query);
$maker_value2 = $maker[bo_category_list];
$maker_value = explode("|",$maker_value2);
$k = count($maker_value);
for ($i=0; $i<$k; $i++) {?>
<option value=<?=$maker_value[$i]?> <?if($tmp==$maker_value[$i]) echo "selected";?>><?=$maker_value[$i]?></option>
<?}?>
</select>
<select name="fsec_genre" size="1">
<option value=''>장르 선택</option>
<option value="스쿠터">스쿠터</option>
<option value="슈퍼스포츠">슈퍼스포츠</option>
<option value="네이키드">네이키드</option>
<option value="크루저">크루저</option>
<option value="차퍼">차퍼</option>
<option value="투어러">투어러</option>
<option value="멀티퍼퍼스">멀티퍼퍼스</option>
<option value="슈퍼모타드">슈퍼모타드</option>
<option value="엔듀로">엔듀로</option>
<option value="ATV">ATV</option>
<option value="비지니스">비지니스</option>
<option value="etc">etc</option>
</select>
<select name="fsec_sel" size="1" onchange="loaddata(fsec_sel.options[fsec_sel.selectedIndex].value);">
<option value=''>배기량 선택</option>
<option value="1|50">50cc이하</option>
<option value="50|125">50cc~125cc</option>
<option value="125|250">125cc~250cc</option>
<option value="250|400">250cc~400cc</option>
<option value="400|600">400cc~600cc</option>
<option value="600|1000">600cc~1000cc</option>
<option value="1000|3000">오버리터급</option>
</select>
<select name='msec_sel'>
<option value=''>기종 선택</option>
</select>
<input type=button value=' + ' onclick=gor()>
<input type=button value=' - ' onclick=gol()>
<select name=sel size=1 multiple>
<input type=hidden name=res size=30>
<input type = "submit">
</form>
</td>
</tr>
<tr><td>
<?
include("comparative.php");
?>
</td></tr>
<tr>
<td colspan="5">
<?
include_once("$g4[path]/tail.php");
?>
</td>
</tr>
</table>
<script>
//다중값 체크 스크립트
function gor()
{
j=document.item_reg.sel.length;
for(var i=0;i<document.item_reg.msec_sel.length;i++)
{
if(document.item_reg.msec_sel.options[i].selected && document.item_reg.msec_sel.options[i].value)
{
document.item_reg.msec_sel.options[i].selected=false;
chk_same=0;
for(var k=0;k<document.item_reg.sel.length;k++)
{
if(document.item_reg.msec_sel.options[i].value==document.item_reg.sel.options[k].value)
{
chk_same=1;
}
}
if(!chk_same)
{ document.item_reg.sel.options[j]=new Option(document.item_reg.msec_sel.options[i].text,document.item_reg.msec_sel.options[i].value);
j++;
}
}
}
get_result()
}
function gol()
{
buff=new Array();
j=0;
for(var i=document.item_reg.sel.length-1;i>=0;i--)
{ if(document.item_reg.sel.options[i].selected && document.item_reg.sel.options[i].value)
{ document.item_reg.sel.options[i] = null; } }
get_result()
}
function get_result()
{res=new Array();
for(var i=0;i<document.item_reg.sel.length;i++)
{res[i]=document.item_reg.sel.options[i].value;}
res=res.join("|");
document.item_reg.res.value=res;
}
</script>
<iframe width='1' height='1' name='get_msec'></iframe>
<? $search = '' ?>
////ex2.php//////
<?
$g4_path = ".."; // common.php 의 상대 경로
include_once("$g4_path/common.php");
include_once("$g4[path]/config.php");
$cc = explode("|",$cc);
$cc1 = $cc[0];
$cc2 = $cc[1];
if($genre) $query2 = " and wr_1 = '$genre'";
if($year) $query3 = " and wr_2 = $year";
if(1<count($cc)) $query4 = " and wr_3 between $cc1 and $cc2";
$qry = sql_query("select wr_id, ca_name, wr_subject from g4_write_bike_search where ca_name= '$fsec'".$query2.$query3.$query4);
$total = mysql_num_rows($qry); //조건을 만족하는 총 목록수
$i=0;
while($res = sql_fetch_array($qry)) {
?>
<!-- test1.php의 2차 셀렉트 박스에 내용을 뿌려주는 스크립트 부분 -->
<script>
//셀렉트 박스 눌렀을때 생기는 목록의 갯수를 지정하는 부분
//이 부분이 없으면 총 목록이 10개여도 하나만 보인다.
parent.item_reg.msec_sel.length=<?=$total?>;
//<option></option>사이에 들어가 화면에 표시되는 이름
parent.item_reg.msec_sel.options[<?=$i?>].text='<?=$res[wr_subject]?>';
//<option value></option>에서 value에 해당하는 값
parent.item_reg.msec_sel.options[<?=$i?>].value='<?=$res[wr_id]?>';
</script>
<?
$i++;
}
?>
0
관련링크
댓글 8개
관리자님의 지역 셀렉트인데 이거 참고해 보시면 될듯 하네요...


http://ilovewonju.kr/bbs/write.php?bo_table=21_01

제가 ajax는 못해서링 ㅠ

구현하시려는게 구체적으로 뭔지 잘 모르겠네요 도움드릴수 있을것 같기도한데

저페이지에서 고를때 실시간으로 이미지 뜨게하는거랑 (이미지 경로는
<?=$g4[path]?>/data/file/bike_search/thumb/<?=$res[$img_i]?> 일케욤)
지금 브랜드명에서 고르는것만되는데 중간에있는 배기량/장르별로도 고를때마다 마지막 모델선택 값이 바뀌게 하는게 목표입니다.ㅠㅠ
그러니까 3가지 셀렉트메뉴가 고정이고 1개만 바뀌는거죠
ajax같은데 잘만드셔씀 ㅠㅠ
뉴비는 그저 웁니다 꺼이꺼이

그럼 섬네일문제도 간단해지고요
셀렉트는 아니지만
http://ilovewonju.kr/bbs/board.php?bo_table=21_01&wr_id=22090
에서 아파트이고 23_02게시판에 아파트 상세정보가있는 아파트 단지를 가져온겁니다.