신청폼에서 특정값을 선택시 다른겂도 변경이 되게 하는 방법 부탁드립니다

신청폼에서 특정값을 선택시 다른겂도 변경이 되게 하는 방법 부탁드립니다

QA

신청폼에서 특정값을 선택시 다른겂도 변경이 되게 하는 방법 부탁드립니다

본문

아래폼에서  

if(field5 == "서울" || field5 == "경기" || field5 == "인천") 

일때는 item_no값이 그대로이고

이외는 <INPUT type=hidden name=item_no value="517">  <---- 517를  600으로 값으로 변경하고자합니다

 

 

 

 

 

<form name="Ins_from" id="form1" action='http://www.naver/aa.php' method="post" onsubmit="return fvalchk(this);" target=hiddenframe>

<INPUT type=hidden name=partner_id value="<?= $partner_id ?>" >

<INPUT type=hidden name=item_no value="517">

<div style="width:98%; height:auto; margin:0 auto; clear:both; zoom:1; zoom:1;">

<center>

<table cellpadding="0" cellspacing="0" border="0" width="100%" align="center">

<tr>

<th align="center" width="30%" class="th00" bgcolor="#f0f0f0"><img src=".images/icon01.png" align="absmiddle"><b style="color:#333;">이름</b></th>

<td align="center" width="30%" class="td00" bgcolor="#ffffff"><input type="text" name="user_name" alt="이름" title="이름" itemname="이름" required class="input01"></td>

</tr>

<tr>

<th align="center" width="30%" class="th01" bgcolor="#f0f0f0"><img src=".images/icon01.png" align="absmiddle"><b style="color:#333;">연락처</b></th>

<td align="center" width="70%" class="td01" bgcolor="#ffffff">

<input type="tel" style="width:27%; height:24px; line-height:24px; margin:5px 0px; border:1px solid #7f9db9; padding:3px;" required name="휴대폰번호1">

<input type="tel" style="width:29%; height:24px; line-height:24px; margin:5px 0px; border:1px solid #7f9db9; padding:3px;" required name="휴대폰번호2">

<input type="tel" style="width:29%; height:24px; line-height:24px; margin:5px 0px; border:1px solid #7f9db9; padding:3px;" required name="휴대폰번호3">

</td>

</tr>

 

<tr>

<th align="center" width="30%" class="th01" bgcolor="#f0f0f0"><img src=".images/icon01.png" align="absmiddle"><b style="color:#333;">성별</b></th>

<td align="center" width="70%" class="td01" bgcolor="#ffffff">

<input type="radio" name="성별" alt="성별" title="성별" itemname="성별" required value="남" class="radio"><b style="color:#333;">남</b>

<input type="radio" name="성별" alt="성별" title="성별" itemname="성별" required value="여" class="radio"><b style="color:#333;">여</b>

</td>

</tr>

<tr>

<th align="center" width="30%" class="th01" bgcolor="#f0f0f0"><img src=".images/icon01.png" align="absmiddle"><b style="color:#333;">거주지역</b></th>

<td align="center" width="70%" class="td01" bgcolor="#ffffff">

<select name="field5" alt="거주지역" title="거주지역" itemname="거주지역" required class="input02">

<option value="">선택하세요</option>

<option value="서울">서울</option>

<option value="경기">경기</option>

<option value="인천">인천</option>

<option value="대전">대전</option>

<option value="부산">부산</option>

<option value="울산">울산</option>

<option value="광주">광주</option>

<option value="대구">대구</option>

<option value="강원">강원</option>

<option value="경남">경남</option>

<option value="경북">경북</option>

<option value="전남">전남</option>

<option value="전북">전북</option>

<option value="충남">충남</option>

<option value="충북">충북</option>

<option value="제주">제주</option>

</select>

</td>

</tr>

<tr>

<th align="center" width="30%" class="th01" bgcolor="#f0f0f0"><img src=".images/icon01.png" align="absmiddle"><b style="color:#333;">상세문의</b></th>

<td align="center" width="70%" class="td01" bgcolor="#ffffff"><input type="text" name="상세문의" alt="상세문의" title="상세문의" itemname="상세문의" required class="input01"></td>

</tr>

</table>

</center>

</div>

<div style="width:90%; clear:both; text-align:center; margin:10px auto;"><input type="checkbox" class="checkbox" title="개인정보 수집/이용 및 취급/위탁에 대한 동의" required name="privacy"> <b style="color:#333;">개인정보 수집/이용 및 취급/위탁에 대한 동의</b></div>

<div style="width:100%; clear:both; text-align:center; margin:0 auto;"><input type="image" src="./images/sinae01/mb_04.jpg" style="width:100%; margin-bottom:20px;"></div>

</form>

이 질문에 댓글 쓰기 :

답변 3


<script>
window.onload = function(){
	var select = document.getElementsByName('field5')[0];
    select.onchange = function(){
    	var obj = event.srcElement;
      var item_no = document.getElementsByName('item_no')[0]; 
       if(obj.value === '서울' || obj.value === '경기' || obj.value === '인천'){
           item_no.value = '600'; 
       }else{
          item_no.value = '517';
       }
    };
};
</script>

적용하니 아래폼에서

<form name="Ins_from" id="form1" action='http://www.naver/aa.php' method="post" onsubmit="return fvalchk(this);" target=hiddenframe>
<INPUT type=hidden name=partner_id value="<?= $partner_id ?>" >
<INPUT type=hidden name=item_no value="517"> <-------- 517 이부분이 변경이 안되던데요

적용하니 아래폼에서

<form name="Ins_from" id="form1" action='http://www.naver/aa.php' method="post" onsubmit="return fvalchk(this);" target=hiddenframe>
<INPUT type=hidden name=partner_id value="<?= $partner_id ?>" >
<INPUT type=hidden name=item_no value="517"> <-------- 517 이부분이 변경이 안되던데요


var f = document.getElementById('form1');
f.field5.onchange = function() {
	 f.item_no.value = '서울,경기,인천'.indexOf(this.value) == -1 ? 600 : 517;
}

적용하니 아래폼에서

<form name="Ins_from" id="form1" action='http://www.naver/aa.php' method="post" onsubmit="return fvalchk(this);" target=hiddenframe>
<INPUT type=hidden name=partner_id value="<?= $partner_id ?>" >
<INPUT type=hidden name=item_no value="517"> <-------- 517 이부분이 변경이 안되던데요

변경 잘되는데요~~

 

https://jsfiddle.net/sukgamoni/ssm3op7x/2/ 

 

 


 
<script>
window.onload = function(){
	var select = document.getElementsByName('field5')[0];
    select.onchange = function(){
    	var obj = event.srcElement;
      var item_no = document.getElementsByName('item_no')[0]; 
       if(obj.value === '서울' || obj.value === '경기' || obj.value === '인천'){
           item_no.value = '600'; 
       }else{
          item_no.value = '517';
       }
    };
};
</script><form name="Ins_from" id="form1" action='http://www.naver/aa.php' method="post" onsubmit="return fvalchk(this);" target=hiddenframe>
   <INPUT type=hidden name=partner_id value="<?= $partner_id ?>" >
   <INPUT type=hidden name=item_no value="517">
   <div style="width:98%; height:auto; margin:0 auto; clear:both; zoom:1; zoom:1;">
      <center>
         <table cellpadding="0" cellspacing="0" border="0" width="100%" align="center">
            <tr>
               <th align="center" width="30%" class="th00" bgcolor="#f0f0f0"><img src=".images/icon01.png" align="absmiddle"><b style="color:#333;">이름</b></th>
               <td align="center" width="30%" class="td00" bgcolor="#ffffff"><input type="text" name="user_name" alt="이름" title="이름" itemname="이름" required class="input01"></td>
            </tr>
            <tr>
               <th align="center" width="30%" class="th01" bgcolor="#f0f0f0"><img src=".images/icon01.png" align="absmiddle"><b style="color:#333;">연락처</b></th>
               <td align="center" width="70%" class="td01" bgcolor="#ffffff">
                  <input type="tel" style="width:27%; height:24px; line-height:24px; margin:5px 0px; border:1px solid #7f9db9; padding:3px;" required name="휴대폰번호1">
                  <input type="tel" style="width:29%; height:24px; line-height:24px; margin:5px 0px; border:1px solid #7f9db9; padding:3px;" required name="휴대폰번호2">
                  <input type="tel" style="width:29%; height:24px; line-height:24px; margin:5px 0px; border:1px solid #7f9db9; padding:3px;" required name="휴대폰번호3">
               </td>
            </tr>
            <tr>
               <th align="center" width="30%" class="th01" bgcolor="#f0f0f0"><img src=".images/icon01.png" align="absmiddle"><b style="color:#333;">성별</b></th>
               <td align="center" width="70%" class="td01" bgcolor="#ffffff">
                  <input type="radio" name="성별" alt="성별" title="성별" itemname="성별" required value="남" class="radio"><b style="color:#333;">남</b>
                  <input type="radio" name="성별" alt="성별" title="성별" itemname="성별" required value="여" class="radio"><b style="color:#333;">여</b>
               </td>
            </tr>
            <tr>
               <th align="center" width="30%" class="th01" bgcolor="#f0f0f0"><img src=".images/icon01.png" align="absmiddle"><b style="color:#333;">거주지역</b></th>
               <td align="center" width="70%" class="td01" bgcolor="#ffffff">
                  <select name="field5" alt="거주지역" title="거주지역" itemname="거주지역" required class="input02">
                     <option value="">선택하세요</option>
                     <option value="서울">서울</option>
                     <option value="경기">경기</option>
                     <option value="인천">인천</option>
                     <option value="대전">대전</option>
                     <option value="부산">부산</option>
                     <option value="울산">울산</option>
                     <option value="광주">광주</option>
                     <option value="대구">대구</option>
                     <option value="강원">강원</option>
                     <option value="경남">경남</option>
                     <option value="경북">경북</option>
                     <option value="전남">전남</option>
                     <option value="전북">전북</option>
                     <option value="충남">충남</option>
                     <option value="충북">충북</option>
                     <option value="제주">제주</option>
                  </select>
               </td>
            </tr>
            <tr>
               <th align="center" width="30%" class="th01" bgcolor="#f0f0f0"><img src=".images/icon01.png" align="absmiddle"><b style="color:#333;">상세문의</b></th>
               <td align="center" width="70%" class="td01" bgcolor="#ffffff"><input type="text" name="상세문의" alt="상세문의" title="상세문의" itemname="상세문의" required class="input01"></td>
            </tr>
         </table>
      </center>
   </div>
   <div style="width:90%; clear:both; text-align:center; margin:10px auto;"><input type="checkbox" class="checkbox" title="개인정보 수집/이용 및 취급/위탁에 대한 동의" required name="privacy"> <b style="color:#333;">개인정보 수집/이용 및 취급/위탁에 대한 동의</b></div>
   <div style="width:100%; clear:both; text-align:center; margin:0 auto;"><input type="image" src="./images/sinae01/mb_04.jpg" style="width:100%; margin-bottom:20px;"></div>
</form>
 
 

 

답변을 작성하시기 전에 로그인 해주세요.
전체 123,622 | RSS
QA 내용 검색

회원로그인

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