SeletBox 이동과 자식폼에서 부모폼으로 값이동
function moveDualList( srcList, destList, moveAll ) {
if ( ( srcList.selectedIndex == -1 ) && ( moveAll == false ) ) {
return;
}newDestList = new Array( destList.options.length );
var len = 0;for( len = 0; len < destList.options.length; len++ ) {
if ( destList.options[ len ] != null ) {
newDestList[ len ] = new Option( destList.options[ len ].text, destList.options[ len ].value, destList.options[ len ].defaultSelected, destList.options[ len ].selected );
}
}for( var i = 0; i < srcList.options.length; i++ ) {
if ( srcList.options[i] != null && ( srcList.options[i].selected == true || moveAll ) ) {
newDestList[ len ] = new Option( srcList.options[i].text, srcList.options[i].value, srcList.options[i].defaultSelected, srcList.options[i].selected );
len++;
}
}newDestList.sort( compareOptionValues ); // BY VALUES
for ( var j = 0; j < newDestList.length; j++ ) {
if ( newDestList[ j ] != null ) {
destList.options[ j ] = newDestList[ j ];
}
}
for( var i = srcList.options.length - 1; i >= 0; i-- ) {
if ( srcList.options[i] != null && ( srcList.options[i].selected == true || moveAll ) ) {
srcList.options[i] = null;
}
}
Movechek(); // 이동시 마다 함수 저장
}
function Movechek(){
tmpStr = document.hp_list.htm_vehicle.value;
var leno = document.forms['hp_list'].elements['htm_vehicle'].options.length; // 셀렉트 박스 갯수
var strValues = "";
var count = 0;
for(i=0; i<leno; i++)
{
//strValues = document.forms['hp_list'].elements['htm_vehicle'].options[I].value;
if (count == 0) {
strValues = document.forms['hp_list'].elements['htm_vehicle'].options[i].value;
}
else {
strValues = strValues + "," + document.forms['hp_list'].elements['htm_vehicle'].options[i].value;
}
count++;
}
if(strValues == "") alert('빈값');
else parent.doSearch(strValues);
}
자식 페이지 스크립트 ▲
자식 페이지 Html ▲<form name ="hp_list">
<table style="border" style="border:solid 1 gray;font-family:Tahoma,Verdana,Arial;font-size:8pt;color:black;background-color:#f6f6f6;" >
<tr>
<td bgcolor="#e8e8e8">
<!-- vehicle list will be filled by model year selection -->
<select multiple size="6" style="width:200" name="available">
<?
$sql="select * from directory where `directory`.`group` ='$click_day' order by idx";
$result=mysql_query($sql);
for($k=0;$k<$row=sql_fetch_array($result);$k++)
{
?>
<option value="<?=$row[directory_num];?>"><?=$row[directory_name]." ".$row[directory_num];?>
<?
}
?></select>
</td>
<td bgcolor="#e8e8e8" xwidth="15%" align="center">
<input type="button" style="width:50" onClick="moveDualList( this.form.available, this.form.htm_vehicle, false )" value=">" id=button2 name=button2><br>
<input type="button" style="width:50" onClick="moveDualList( this.form.htm_vehicle, this.form.available, false )" value="<" id=button3 name=button3><br>
<input type="button" style="width:50" onClick="moveDualList( this.form.available, this.form.htm_vehicle, true )" value=">>" id=button4 name=button4><br>
<input type="button" style="width:50" onClick="moveDualList( this.form.htm_vehicle, this.form.available, true )" value="<<" id=button5 name=button5><br>
</td>
<td bgcolor="#e8e8e8">
<select multiple size="6" style="width:180" name="htm_vehicle">
</select>
</td>
</form>
</table>
function doSearch(hp_num) // 자식값 받아오기부모 스크립트 ▲
{
document.sms.hp_num.value = hp_num;
}
정리 =
이소스는 한페이지 안에 2페이지가 있다 (iframe)
자식에서 이벤트가 일어 날때마다 부모 함수 안에 저장해서
최종적으로 부모가 다른 페이지로 값을 넘길때 다같이 보낼수 있도록 했다
(설명이 어렵네..ㅋ)
