셀렉트메뉴 문의입니다~
오류가 나는곳의 주소를 알려주시면 더 빠르고 정확하게 답변 받을 수 있습니다.
오류 주소 :
첫번째메뉴 선택시 첫번째에 해당하는 두번째 메뉴가 셀렉트박스에 출력됩니다.
두번째메뉴 선택시 그아래 3번째 메뉴항목이 출력되게 하고싶습니다.
스크립트와 폼을 어떻게 수정 또는 추가해야할까요?
여기서 중요한건 메뉴3이 자동출력되게 한다는게 중요합니다//
형태--------------
메뉴1 > 메뉴2
메뉴3(1) 메뉴3(2) 메뉴3(3)
메뉴3(4) 메뉴3(5) 메뉴3(6)
<script language="javascript">
<!--
function Category(value, url) {
this.value = value;
this.url = url;
this.length = 0;
}
function addCategory(category, value, url) {
category[category.length] = new Category(value, url);
category.length++;
}
var category = new Category();
addCategory(category, "HP", null);
addCategory(category[0], "=== 선택하세요 ===", null);
addCategory(category[0], "프린터", "/shop/shopbrand.html?xcode=020&mcode=001&scode=001&type=X" );
addCategory(category[0], "복합기", "/shop/shopbrand.html?xcode=020&mcode=001&scode=002&type=X" );
addCategory(category, "EPSON", null);
addCategory(category[1], "=== 선택하세요 ===", null);
addCategory(category[1], "프린터", "#" );
addCategory(category[1], "복합기", "#" );
addCategory(category, "BROTHER", null);
addCategory(category[2], "=== 선택하세요 ===", null);
addCategory(category[2], "프린터", "#" );
addCategory(category[2], "복합기", "#" );
function initForm(form) {
form.subject.length = category.length;
for (i = 0; i < category.length; i++)
form.subject[i].text = category[i].value;
form.subject.selectedIndex = 0;
form.contents.selectedIndex = 0;
change_subject(form);
}
function change_subject(form) {
var i = form.subject.selectedIndex;
form.contents.length = category[i].length;
for (j = 0; j < form.contents.length; j++)
form.contents[j].text = category[i][j].value;
form.contents.selectedIndex = 0;
// change_contents(form);
}
function change_contents(form) {
var i = form.subject.selectedIndex
var j = form.contents.selectedIndex;
if(category[i][j].url != null)
location.href=category[i][j].url;
}
// -->
</script>
<!--/script_scroll(1)/-->
<div id="wrap">
<!--/include_header(1)/-->
<div id="contentWrapper">
<div id="contentWrap">
<div id="content">
<div class="category_title_img">
<!--/category_title_html/-->
</div>
<body onLoad="initForm(document.form)">
<div id="category">
<form name="form" method="get" action="#">홈 >
<select name="subject" onchange="change_subject(this.form)" style="width:160px;"></select> >
<select name="contents" onchange="change_contents(this.form)" style="width:160px;"></select>
</form>
</div>
<!--상품목록시작-->
오류 주소 :
첫번째메뉴 선택시 첫번째에 해당하는 두번째 메뉴가 셀렉트박스에 출력됩니다.
두번째메뉴 선택시 그아래 3번째 메뉴항목이 출력되게 하고싶습니다.
스크립트와 폼을 어떻게 수정 또는 추가해야할까요?
여기서 중요한건 메뉴3이 자동출력되게 한다는게 중요합니다//
형태--------------
메뉴1 > 메뉴2
메뉴3(1) 메뉴3(2) 메뉴3(3)
메뉴3(4) 메뉴3(5) 메뉴3(6)
<script language="javascript">
<!--
function Category(value, url) {
this.value = value;
this.url = url;
this.length = 0;
}
function addCategory(category, value, url) {
category[category.length] = new Category(value, url);
category.length++;
}
var category = new Category();
addCategory(category, "HP", null);
addCategory(category[0], "=== 선택하세요 ===", null);
addCategory(category[0], "프린터", "/shop/shopbrand.html?xcode=020&mcode=001&scode=001&type=X" );
addCategory(category[0], "복합기", "/shop/shopbrand.html?xcode=020&mcode=001&scode=002&type=X" );
addCategory(category, "EPSON", null);
addCategory(category[1], "=== 선택하세요 ===", null);
addCategory(category[1], "프린터", "#" );
addCategory(category[1], "복합기", "#" );
addCategory(category, "BROTHER", null);
addCategory(category[2], "=== 선택하세요 ===", null);
addCategory(category[2], "프린터", "#" );
addCategory(category[2], "복합기", "#" );
function initForm(form) {
form.subject.length = category.length;
for (i = 0; i < category.length; i++)
form.subject[i].text = category[i].value;
form.subject.selectedIndex = 0;
form.contents.selectedIndex = 0;
change_subject(form);
}
function change_subject(form) {
var i = form.subject.selectedIndex;
form.contents.length = category[i].length;
for (j = 0; j < form.contents.length; j++)
form.contents[j].text = category[i][j].value;
form.contents.selectedIndex = 0;
// change_contents(form);
}
function change_contents(form) {
var i = form.subject.selectedIndex
var j = form.contents.selectedIndex;
if(category[i][j].url != null)
location.href=category[i][j].url;
}
// -->
</script>
<!--/script_scroll(1)/-->
<div id="wrap">
<!--/include_header(1)/-->
<div id="contentWrapper">
<div id="contentWrap">
<div id="content">
<div class="category_title_img">
<!--/category_title_html/-->
</div>
<body onLoad="initForm(document.form)">
<div id="category">
<form name="form" method="get" action="#">홈 >
<select name="subject" onchange="change_subject(this.form)" style="width:160px;"></select> >
<select name="contents" onchange="change_contents(this.form)" style="width:160px;"></select>
</form>
</div>
<!--상품목록시작-->
댓글 2개
12년 전
http://sensible_ar.blog.me/167275657
퇴근후밥상
12년 전
굉장히 유용한 소스인거 같은데 ㅠㅠ 제가 자바스크립트를 잘 몰라서요 ㅜㅜ 저위소스에 적용을 하려면 어떻게 응용을 해야하나요?
게시판 목록
그누5 질답
그누보드5 버전에 대한 질문을 할 수 있습니다.
쪽지나 메일로 해결해 주겠다는 답변은 정상적인 답변으로 보기 어려우므로 신고해 주시기 바랍니다.
쪽지나 메일로 해결해 주겠다는 답변은 정상적인 답변으로 보기 어려우므로 신고해 주시기 바랍니다.
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|
| 883 | 12년 전 | 318 | ||
| 882 | 12년 전 | 667 | ||
| 881 |
Unhappy
|
12년 전 | 399 | |
| 880 | 12년 전 | 394 | ||
| 879 | 12년 전 | 370 | ||
| 878 |
cycix
|
12년 전 | 1239 | |
| 877 | 12년 전 | 564 | ||
| 876 |
beatle
|
12년 전 | 263 | |
| 875 | 12년 전 | 434 | ||
| 874 | 12년 전 | 421 | ||
| 873 |
오렌지맛스타
|
12년 전 | 634 | |
| 872 | 12년 전 | 804 | ||
| 871 | 12년 전 | 276 | ||
| 870 | 12년 전 | 420 | ||
| 869 | 12년 전 | 314 | ||
| 868 | 12년 전 | 582 | ||
| 867 | 12년 전 | 621 | ||
| 866 |
|
12년 전 | 497 | |
| 865 |
퍼레버의리
|
12년 전 | 321 | |
| 864 | 12년 전 | 388 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기