몇가지 셀렉트 목록을 클릭시에 해당하는 일정한 값이 나오게 견적소스를 짯는데 오류가 나와요.ㅜ.ㅜ

몇가지 셀렉트 목록을 클릭시에 해당하는 일정한 값이 나오게 견적소스를 짯는데 오류가 나와요.ㅜ.ㅜ

QA

몇가지 셀렉트 목록을 클릭시에 해당하는 일정한 값이 나오게 견적소스를 짯는데 오류가 나와요.ㅜ.ㅜ

본문

<div>&lt;form name="frm" id="frm" action=""&gt;  <br />&lt;select id="product"&gt;  <br />&lt;option value=1000&gt;컴퓨터A&lt;/option&gt;  <br />&lt;option value=1500&gt;컴퓨터B&lt;/option&gt;  <br />&lt;/select&gt; &lt;br /&gt; <br />&lt;select id="rent_time"&gt;  <br />&lt;option value=45000&gt;12개월&lt;/option&gt;  <br />&lt;option value=90000&gt;24개월&lt;/option&gt;  <br />&lt;/select&gt; &lt;br /&gt; <br />&lt;select id="rent" onchange="javascript:sum();"&gt;  <br />&lt;option value=90000&gt;소유권이전&lt;/option&gt;  <br />&lt;option value=35000&gt;소유권반납&lt;/option&gt;  <br />&lt;/select&gt; &lt;br /&gt; <br />&lt;input type="text" name="opt_sum" value="" /&gt;  <br />&lt;/form&gt;  <br />&lt;script&gt; <br />function sum() {  <br />var opt_sum;  <br />var frm=document.frm;  <br />if(frm.product.value==1000 &amp;&amp; frm.rent_time.value==45000 &amp;&amp; frm.rent.value==90000) { <br />&nbsp;opt_sum=1459;  <br />}elseif(frm.product.value==1000 &amp;&amp; frm.rent_time.value==45000 &amp;&amp; frm.rent.value==35000) { //이줄에 드림위버 숫자에  <br />&nbsp;opt_sum=14535;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 빨간마크가 떳어요. <br />}elseif(frm.product.value==1000 &amp;&amp; frm.rent_time.value==90000 &amp;&amp; frm.rent.value==90000) { <br />&nbsp;opt_sum=199;  <br />}elseif(frm.product.value==1000 &amp;&amp; frm.rent_time.value==90000 &amp;&amp; frm.rent.value==35000) { <br />&nbsp;opt_sum=1935;  <br />}elseif(frm.product.value==1500 &amp;&amp; frm.rent_time.value==45000 &amp;&amp; frm.rent.value==90000) { <br />&nbsp;opt_sum=1459;  <br />}elseif(frm.product.value==1500 &amp;&amp; frm.rent_time.value==45000 &amp;&amp; frm.rent.value==35000) { <br />&nbsp;opt_sum=14535;  <br />}elseif(frm.product.value==1500 &amp;&amp; frm.rent_time.value==90000 &amp;&amp; frm.rent.value==90000) { <br />&nbsp;opt_sum=199;  <br />}else(frm.product.value==1500 &amp;&amp; frm.rent_time.value==90000 &amp;&amp; frm.rent.value==35000) { <br />&nbsp;opt_sum=1935;  <br /><br />frm.opt_sum.value=opt_sum;  <br />} <br />&lt;/script&gt; </div>
<div>&nbsp;</div>
<div>&nbsp;</div>
<div>보시는대로 해당소스를 페이지에 넣으니 결과값이 안나오고잇어요. 그냥 빈칸이 나와요.</div>
<div>지금소스에서는 드림위에 줄수에 빨간마크가 떳구여..ㅜ.ㅜ.</div>
<div>어디가 잘못된건지... 감이 안옵니다. 부디 살펴봐 주십시오.</div>
<div>&nbsp;</div>

이 질문에 댓글 쓰기 :

답변 2

opt_sum=1935; 

이부분을

document.all.frm.opt_sum = '1935';

이런식으로 해보세요

<form name="frm" id="frm" action="">
<select id="product">
<option value=1000>컴퓨터A</option>
<option value=1500>컴퓨터B</option>
</select> <br />
<select id="rent_time">
<option value=45000>12개월</option>
<option value=90000>24개월</option>
</select> <br />
<select id="rent" onchange="javascript:sum();">
<option value=90000>소유권이전</option>
<option value=35000>소유권반납</option>
</select> <br />
<input type="text" name="opt_sum" value="" />
</form>
<script>
function sum() {
var opt_sum;
var frm=document.frm;
if(frm.product.value==1000 && frm.rent_time.value==45000 && frm.rent.value==90000) {
document.all.frm.opt_sum = '1459';
}elseif(frm.product.value==1000 && frm.rent_time.value==45000 && frm.rent.value==35000) {
document.all.frm.opt_sum = '14535';
}elseif(frm.product.value==1000 && frm.rent_time.value==90000 && frm.rent.value==90000) {
document.all.frm.opt_sum = '199';
}elseif(frm.product.value==1000 && frm.rent_time.value==90000 && frm.rent.value==35000) {
document.all.frm.opt_sum = '1935';
}elseif(frm.product.value==1500 && frm.rent_time.value==45000 && frm.rent.value==90000) {
document.all.frm.opt_sum = '15459';
}elseif(frm.product.value==1500 && frm.rent_time.value==45000 && frm.rent.value==35000) {
document.all.frm.opt_sum = '154535';
}elseif(frm.product.value==1500 && frm.rent_time.value==90000 && frm.rent.value==90000) {
document.all.frm.opt_sum = '1599';
}else(frm.product.value==1500 && frm.rent_time.value==90000 && frm.rent.value==35000) {
document.all.frm.opt_sum = '15935';
}
frm.opt_sum.value=opt_sum;

</script>

이렇게 바꿔도 22번째줄 숫자에 빨간 네모가 뜨고 셀렉트칸 목록을 바꿔봐도 여전히 결과 칸에는 아무런 표시가 안떠요
제가 잘못 바꾼거 같습니다.. 다시 알려주시면 감사합니다. ㅠ,ㅠ 꾸벅


<script>
function sum() {
    var f = document.frm;
	f.opt_sum.value = 1 + trim(f.rent_time.value) + trim(f.rent.value);
}
function trim(str) {
    return str.replace(/0/g,'');
}
</script>
답변을 작성하시기 전에 로그인 해주세요.
전체 93
QA 내용 검색

회원로그인

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