Develop

[js] selectbox 선택 후 input 박스에 적용

by hooni posted Apr 23, 2013
?

단축키

Prev이전 문서

Next다음 문서

ESC닫기

크게 작게 위로 아래로 댓글로 가기 인쇄

상민이가 부탁했던거.. ㅋㅋ

input 박스 속성 바꾸는거 포함..

메일주소 호스트 자동완성 스크립트


# 데모

@
@


# Javascript 코드

<script language="javascript">
function changeSelect(s,no){
    form = document.MemberForm;
    sel = s[s.selectedIndex].value;
    dis = 1;

    if(sel=="user"){
        sel = "";
        dis = 0;
    }

    if(no==1){
        form.EmailDomain1.value = sel;
        form.EmailDomain1.disabled = dis;
    }else{
        form.EmailDomain2.value = sel;
        form.EmailDomain2.disabled = dis;
    }
}
</script>


# HTML 코드

<form name="MemberForm" method="post"
    action="info.asp" onsubmit="return false;">

    <input type="Hidden" name="EditValue1" />
    <INPUT type="text" name="EmailID1" size="8" />
    @
    <INPUT type="text" name="EmailDomain1" size="8" />
    
    <SELECT name="SelEmailDomain1" onchange="changeSelect(this,1);">
        <option value="">메일주소선택</option>
        <option value='hanafos.com'>하나포스닷컴</option>
        <option value='naver.com'>네이버</option>
        <option value='paran.com'>파란</option>
        <option value='empal.com'>엠파스</option>
        <option value='nate.com'>네이트</option>
        <option value='yahoo.co.kr'>야후코리아</option>
        <option value='dreamwiz.com'>드림위즈</option>
        <option value='freechal.com'>프리챌</option>
        <option value='hotmail.com'>핫메일</option>
        <option value='korea.com'>코리아닷컴</option>
        <option value='chollian.net'>천리안</option>
        <option value='hanmail.net'>한메일</option>
        <option value="user">직접입력</option>
    </SELECT>
    
    <br/>
    
    <input type="Hidden" name="EditValue2" />
    <INPUT type="text" name="EmailID2" size="8" />
    @
    <INPUT type="text" name="EmailDomain2" size="8" />
    
    <SELECT name="SelEmailDomain2" onchange="changeSelect(this,2);">
        <option value="">메일주소선택</option>
        <option value='hanafos.com'>하나포스닷컴</option>
        <option value='naver.com'>네이버</option>
        <option value='paran.com'>파란</option>
        <option value='empal.com'>엠파스</option>
        <option value='nate.com'>네이트</option>
        <option value='yahoo.co.kr'>야후코리아</option>
        <option value='dreamwiz.com'>드림위즈</option>
        <option value='freechal.com'>프리챌</option>
        <option value='hotmail.com'>핫메일</option>
        <option value='korea.com'>코리아닷컴</option>
        <option value='chollian.net'>천리안</option>
        <option value='hanmail.net'>한메일</option>
        <OPTION value="user">직접입력</option>
    </SELECT>

</form>