게시판 글쓰기 할때 2차 셀렉트 연동문제.. > 그누4 질문답변

그누4 질문답변

그누보드4 관련 질문은 QA 로 이전됩니다. QA 그누보드4 바로가기
기존 게시물은 열람만 가능합니다.

게시판 글쓰기 할때 2차 셀렉트 연동문제.. 정보

게시판 글쓰기 할때 2차 셀렉트 연동문제..

본문

게시판 글쓰기 할때

첨부파일처럼

1차 항목을 선택하면 그에 따라 2차 항목이 바뀌고

1차,2차 항목 값이 게시판에 저장 되는 셀렉트 필드를 만들고 싶은데

일반 스크립트를 쓰니 연동이 안되네요 ;;


혹시 아시는 분.. 구조요청 합니다 ㅎㅎ;;

구조해주세요!!



오류가 나는곳의 주소를 알려주시면 더 빠르고 정확하게 답변 받을 수 있습니다.

오류 주소 :

댓글 전체

<script language="JavaScript"><!--
a1 = new Array( "디젤식",
                "LPG식",
                "전동식",
                "견인/운반차",
                "스키드로다",
                "어테치");
suba = new Array();
suba["메인카타고리 선택"] = new Array("메인카타고리를 선택하세요.");

suba["디젤식"] = new Array( "HDF15/18-5",
                                "FOLEX 20D/25D/30D/33D",
                                "FOLEX 35D/40D/45D",
                                "HDF50/70-7",
                                "FOLEX 100D/120D/135D/160D");
suba["LPG식"] = new Array( "FOLEX 20L/25L/30L",
                                "FOLEX 15L/18L/20LA");
suba["전동식"] = new Array( "FOLEX 16/18/20B AC",
                                "FOLEX 22/25/30/32BAC",
                                "FOLEX 35/40/45/50BAC",
                                "FOLEX 15/18/20BT AC",
                                "HBR14/15/18/20/25-7");
suba["견인/운반차"] = new Array( "FOLEX 40T/15P");
suba["스키드로다"] = new Array( "HSL 550-7",
                                "HSL 650-7",
"HSL 850-7");
suba["어테치"] = new Array( "-어테치-");

function view_cat1(inForm) {
    inForm.cat1.options.length = a1.length + 1;
    inForm.cat1.options[0] = new Option("1차선택", "notset", true, false);
    for (var i = 1; i <= a1.length; i++) {
        inForm.cat1.options[i] = new Option(a1[i-1]);
    }
}
function view_cat2(inForm) {
    var s = inForm.cat1.options[inForm.cat1.selectedIndex].text;
    inForm.cat2.options.length = suba[s].length + 1;
    inForm.cat2.options[0] = new Option("2차항목", "notset", true, false);
    for (var i = 1; i <= suba[s].length; i++) {
        inForm.cat2.options[i] = new Option(suba[s][i-1]);
    }
}
//-->
</script>
<onLoad=view_cat1(window.document.Form)>
<FORM name=Form>
<select name=cat1 onChange=view_cat2(this.form)>
<option>1차선택</option>
</select>

<select name=cat2>
<option>2차항목</option>
</select>
</FORM>


이렇게 입력했는데 흠.. 안되네요..
<Script Language='javaScript'>
<!--
//==========================================================//
// Element 및 값 정의
//==========================================================//

FirstSelectName = "sel1";// 처음 Select Element의 이름
SecondSelectName = "sel2";// 두번째 Select Element의 이름

FirstSelectText = new Array("디젤식","LPG식","전동식","견인/운반차","스키드로다","어테치");
FirstSelectValue = new Array("a","b","c","d","e","f");

SecondSelectText = new Array();
SecondSelectValue = new Array();

SecondSelectText[0] = new Array("HDF15/18-5","FOLEX 20D/25D/30D/33D","FOLEX 35D/40D/45D","HDF50/70-7","FOLEX 100D/120D/135D/160D");
SecondSelectText[1] = new Array("FOLEX 20L/25L/30L","FOLEX 15L/18L/20LA");
SecondSelectText[2] = new Array("FOLEX 16/18/20B AC","FOLEX 22/25/30/32BAC","FOLEX 35/40/45/50BAC","FOLEX 15/18/20BT AC","HBR14/15/18/20/25-7");
SecondSelectText[3] = new Array("FOLEX 40T/15P");
SecondSelectText[4] = new Array("HSL 550-7","HSL 650-7","HSL 850-7");
SecondSelectText[5] = new Array("-어테치-");
SecondSelectValue[0] = new Array("HDF15/18-5","FOLEX 20D/25D/30D/33D","FOLEX 35D/40D/45D","HDF50/70-7","FOLEX 100D/120D/135D/160D");
SecondSelectValue[1] = new Array("FOLEX 20L/25L/30L","FOLEX 15L/18L/20LA");
SecondSelectValue[2] = new Array("FOLEX 16/18/20B AC","FOLEX 22/25/30/32BAC","FOLEX 35/40/45/50BAC","FOLEX 15/18/20BT AC","HBR14/15/18/20/25-7");
SecondSelectValue[3] = new Array("FOLEX 40T/15P");
SecondSelectValue[4] = new Array("HSL 550-7","HSL 650-7","HSL 850-7");
SecondSelectValue[5] = new Array("-어테치-");
//==========================================================//
//-->
</script>


<Script Language='JavaScript'>
<!--
// 현재의 Element들이 속해있는 form의 위치를 자동으로 찾차주는 함수
thisFormCheckString = "This_is_Dynamic_Select_Form";
document.write("<input type='hidden' name='"+thisFormCheckString+"'>");
function FindThisFormName()
{
    var d = document;
    var n = d.forms.length;
    if(n == 0)return 0;

    for(var i=0;i<n;i++)
    {
        var e = d.forms[i].elements;
        for(var x=0;x<e.length;x++)
        {
            if(e[x].name == thisFormCheckString)
            return i;
        }
    }

    return "_Nothing_";
}

thisFormName = FindThisFormName();// 현재폼
if(thisFormName == "_Nothing_")
{
    var FormIsCreated = "Dynamic_Select_Form";
    thisFormName = FormIsCreated;
    document.write("<form name='"+FormIsCreated+"'>");
}

function CreateSecondSelect()
{
    var f = document.forms[thisFormName];
    var n = f[FirstSelectName].selectedIndex;
    var l = SecondSelectText[n].length;
    f[SecondSelectName].options.length = l;

    for(var i=0;i<l;i++)
    {
        f[SecondSelectName].options[i].text = SecondSelectText[n][i];
        f[SecondSelectName].options[i].value = SecondSelectValue[n][i];
    }
    f[SecondSelectName].selectedIndex=0;
}
//-->
</script>


<Script Language='JavaScript'>
<!--
document.write("<select name='"+FirstSelectName+"' onChange='CreateSecondSelect()'>");
for(var i=0;i < FirstSelectText.length;i++)
document.write("<option value='"+FirstSelectValue[i]+"'>"+FirstSelectText[i]+"</option>");
document.write("</select>");
//-->
</script>


<Script Language='JavaScript'>
<!--
document.write("<select name='"+SecondSelectName+"'>");
document.write("<option value=''></option>");
document.write("</select>");

if(FormIsCreated) document.write("</form>");
CreateSecondSelect();
//-->
</script>


검색해서 찾은 소스로 이렇게 해서 제대로 표시는 되는데 글 작성을 해도 게시판 확인하면 내용이 안올라가네요..
추가해야 할게 어떤 부분인지;;;;
전체 66,554 |RSS
그누4 질문답변 내용 검색

회원로그인

(주)에스아이알소프트 / 대표:홍석명 / (06211) 서울특별시 강남구 역삼동 707-34 한신인터밸리24 서관 1402호 / E-Mail: admin@sir.kr
사업자등록번호: 217-81-36347 / 통신판매업신고번호:2014-서울강남-02098호 / 개인정보보호책임자:김민섭(minsup@sir.kr)
© SIRSOFT