GNUAPP

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

· 14년 전 · 577
안녕하세요. 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,964
14년 전 조회 1,522
14년 전 조회 1,154
14년 전 조회 3,228
14년 전 조회 1,684
14년 전 조회 1,150
14년 전 조회 1,008
14년 전 조회 1,699
14년 전 조회 1,111
14년 전 조회 888
14년 전 조회 839
14년 전 조회 2,081
14년 전 조회 747
14년 전 조회 978
14년 전 조회 1,757
14년 전 조회 1,077
14년 전 조회 1,079
14년 전 조회 1,623
14년 전 조회 1,287
14년 전 조회 1,355
14년 전 조회 1,152
14년 전 조회 2,458
14년 전 조회 1,247
14년 전 조회 952
14년 전 조회 1,145
14년 전 조회 902
14년 전 조회 932
14년 전 조회 767
14년 전 조회 976
14년 전 조회 1,357
14년 전 조회 1,576
14년 전 조회 1,042
14년 전 조회 1,203
14년 전 조회 1,045
14년 전 조회 1,243
14년 전 조회 1,507
14년 전 조회 1,273
14년 전 조회 1,493
14년 전 조회 1,237
14년 전 조회 1,178
14년 전 조회 1,201
14년 전 조회 1,154
14년 전 조회 1,690
14년 전 조회 1,643
14년 전 조회 1,449
14년 전 조회 1,536
14년 전 조회 1,777
14년 전 조회 772
14년 전 조회 1,231
14년 전 조회 578
14년 전 조회 1,062
14년 전 조회 1,526
14년 전 조회 982
14년 전 조회 1,036
14년 전 조회 1,273
14년 전 조회 1,472
14년 전 조회 1,324
14년 전 조회 1,023
14년 전 조회 1,301
14년 전 조회 1,544
14년 전 조회 1,485
14년 전 조회 1,048
14년 전 조회 2,238
14년 전 조회 560
14년 전 조회 1,209
14년 전 조회 1,042
14년 전 조회 893
14년 전 조회 1,388
14년 전 조회 1,827
14년 전 조회 1,161
14년 전 조회 942
14년 전 조회 955
14년 전 조회 1,229
14년 전 조회 1,524
14년 전 조회 1,621
14년 전 조회 703
14년 전 조회 1,222
14년 전 조회 1,133
14년 전 조회 1,153
14년 전 조회 1,884
14년 전 조회 1,665
14년 전 조회 1,522
14년 전 조회 1,271
14년 전 조회 1,290
14년 전 조회 1,893
14년 전 조회 934
14년 전 조회 699
14년 전 조회 985
14년 전 조회 948
14년 전 조회 1,452
14년 전 조회 1,710
14년 전 조회 1,469
14년 전 조회 1,083
14년 전 조회 1,149
14년 전 조회 1,244
14년 전 조회 2,979
14년 전 조회 1,177
14년 전 조회 1,838
14년 전 조회 1,455
14년 전 조회 1,084