GNUAPP

3단셀렉트 오류문의를 드립니다.

· 14년 전 · 500
안녕하세요. 3단셀렉트 오류문의를 드립니다.

셀렉트에 오류가 있는것 같아요.
셀렉트 1번에 항목이 3개면, 2번이 2개더라도 3개로 나와버려요.
앞의 수량을 뒤에 셀렉트가 그대로 가져가는것 같아요.
아래는 적용한 3단셀렉트 소스입니다.
어디 부분에 오류가 있는것 같은데, 고수님들의 도움 부탁 드립니다.



3단 셀렉트 소스

<SCRIPT LANGUAGE="JavaScript">
<!--
// select a의 선택 값을 이용해 select b의 선택 값을 생성
function change_option_a(form) {
if(form.coa.options[form.coa.selectedIndex].value != 0) {
// 예를들어 select a에서 선택된 값의 value가 s1이라고 했을시 아래 명령과 동일하다
// change_option_a_s1(form);
eval('change_option_a_'+form.coa.options[form.coa.selectedIndex].value+'(form);');
} else {
// value값으로 0을 가지는option을 선택시 명령
}
}

// select b의 선택 값을 이용해 select c의 선택 값을 생성
function change_option_b(form) {
if(form.cob.options[form.cob.selectedIndex].value != 0) {
// 예를들어 select b에서 선택된 값의 value가 s11이라고 했을시 아래 명령과 동일하다
// change_option_a_s11(form);
eval('change_option_b_'+form.cob.options[form.cob.selectedIndex].value+'(form);');
} else {
// value값으로 0을 가지는option을 선택시 명령
}
}

// select a,b,c에서 선택한 text와 value값을 출력
function change_option_result(form) {
// text
alert('[Text]\nSELECT A : '+form.coa.options[form.coa.selectedIndex].text+ // select a
'\nSELECT B : '+form.cob.options[form.cob.selectedIndex].text+ // select b
'\nSELECT C : '+form.coc.options[form.coc.selectedIndex].text+ // select c
'\n\n========================='+
// value
'\n\n[Value]\nSELECT A : '+form.coa.options[form.coa.selectedIndex].value+ // select a
'\nSELECT B : '+form.cob.options[form.cob.selectedIndex].value+ // select b
'\nSELECT C : '+form.coc.options[form.coc.selectedIndex].value); // select c
}

// select a에서 select 1을 선택시 select b에서 보여지는 값
function change_option_a_s1(form) {
form.cob.options[0] = new Option("SELECT B 1",0); // new Option('text','value');
form.cob.options[1] = new Option("Select 1 1","s11");
form.cob.options[2] = new Option("Select 1 2","s12");
form.cob.options[3] = new Option("Select 1 3","s13");
}

// select a에서 select 2를 선택시 select b에서 보여지는 값
function change_option_a_s2(form) {
form.cob.options[0] = new Option("SELECT B 2",0);
form.cob.options[1] = new Option("Select 2 1","s21");
form.cob.options[2] = new Option("Select 2 2","s22");
}

// select b에서 select 1 1을 선택시 select c에서 보여지는 값
function change_option_b_s11(form) {
form.coc.options[0] = new Option("SELECT C 1 1",0);
form.coc.options[1] = new Option("Select 1 1 1","s111");
form.coc.options[2] = new Option("Select 1 1 2","s112");
}

// select b에서 select 1 2를 선택시 select c에서 보여지는 값
function change_option_b_s12(form) {
form.coc.options[0] = new Option("SELECT C 1 2",0);
form.coc.options[1] = new Option("Select 1 2 1","s121");
form.coc.options[2] = new Option("Select 1 2 2","s122");
}

// select b에서 select 2 1을 선택시 select c에서 보여지는 값
function change_option_b_s21(form) {
form.coc.options[0] = new Option("SELECT C 2 1",0);
form.coc.options[1] = new Option("Select 2 1 1","s211");
form.coc.options[2] = new Option("Select 2 1 2","s212");
}

// select b에서 select 2 2를 선택시 select c에서 보여지는 값
function change_option_b_s22(form) {
form.coc.options[0] = new Option("SELECT C 2 2",0);
form.coc.options[1] = new Option("Select 2 2 1","s221");
form.coc.options[2] = new Option("Select 2 2 2","s222");
}
//-->
</SCRIPT>

<FORM NAME="form">

<SELECT NAME="coa" onChange="change_option_a(this.form);">
<OPTION VALUE="0">SELECT A</OPTION>
<OPTION VALUE="s1">Select 1</OPTION>
<OPTION VALUE="s2">Select 2</OPTION>
</SELECT>

<SELECT NAME="cob" onChange="change_option_b(this.form);">
<OPTION VALUE="0">SELECT B</OPTION>
</SELECT>

<SELECT NAME="coc">
<OPTION VALUE="0">SELECT C</OPTION>
</SELECT>

<INPUT TYPE="button" VALUE="click" onClick="change_option_result(this.form);">

</FORM><div class='small'>[이 게시물은 관리자님에 의해 2011-10-31 17:16:08 PHP & HTML에서 이동 됨]</div>
|
댓글을 작성하시려면 로그인이 필요합니다.

프로그램

+
제목 글쓴이 날짜 조회
14년 전 조회 1,873
14년 전 조회 1,430
14년 전 조회 1,076
14년 전 조회 3,151
14년 전 조회 1,603
14년 전 조회 1,068
14년 전 조회 922
14년 전 조회 1,608
14년 전 조회 1,028
14년 전 조회 824
14년 전 조회 755
14년 전 조회 1,995
14년 전 조회 661
14년 전 조회 895
14년 전 조회 1,665
14년 전 조회 998
14년 전 조회 988
14년 전 조회 1,530
14년 전 조회 1,208
14년 전 조회 1,269
14년 전 조회 1,075
14년 전 조회 2,369
14년 전 조회 1,168
14년 전 조회 863
14년 전 조회 1,058
14년 전 조회 810
14년 전 조회 840
14년 전 조회 671
14년 전 조회 876
14년 전 조회 1,263
14년 전 조회 1,483
14년 전 조회 961
14년 전 조회 1,116
14년 전 조회 966
14년 전 조회 1,155
14년 전 조회 1,422
14년 전 조회 1,188
14년 전 조회 1,389
14년 전 조회 1,161
14년 전 조회 1,095
14년 전 조회 1,117
14년 전 조회 1,062
14년 전 조회 1,607
14년 전 조회 1,549
14년 전 조회 1,348
14년 전 조회 1,454
14년 전 조회 1,689
14년 전 조회 684
14년 전 조회 1,137
14년 전 조회 501
14년 전 조회 973
14년 전 조회 1,437
14년 전 조회 903
14년 전 조회 956
14년 전 조회 1,177
14년 전 조회 1,384
14년 전 조회 1,236
14년 전 조회 931
14년 전 조회 1,226
14년 전 조회 1,461
14년 전 조회 1,396
14년 전 조회 956
14년 전 조회 2,150
14년 전 조회 468
14년 전 조회 1,108
14년 전 조회 954
14년 전 조회 796
14년 전 조회 1,290
14년 전 조회 1,731
14년 전 조회 1,087
14년 전 조회 852
14년 전 조회 864
14년 전 조회 1,133
14년 전 조회 1,435
14년 전 조회 1,532
14년 전 조회 602
14년 전 조회 1,141
14년 전 조회 1,043
14년 전 조회 1,067
14년 전 조회 1,779
14년 전 조회 1,555
14년 전 조회 1,435
14년 전 조회 1,190
14년 전 조회 1,198
14년 전 조회 1,807
14년 전 조회 844
14년 전 조회 604
14년 전 조회 890
14년 전 조회 869
14년 전 조회 1,373
14년 전 조회 1,625
14년 전 조회 1,381
14년 전 조회 997
14년 전 조회 1,063
14년 전 조회 1,149
14년 전 조회 2,883
14년 전 조회 1,080
14년 전 조회 1,737
14년 전 조회 1,365
14년 전 조회 982