오른쪽에 3 개의 드롭 다운 상자에 값이 있으며 더 많은 항목이 있습니다 (약 20 개의 드롭 다운 상자를 추가하여 항목의 최종 가격을 제공함). 다음은 HTML 코드입니다 .Javascript가 변수를 함께 추가하지 못합니다.
<form id="myform1>
<p>Testing 1</p>
<select id="Test1">
<option value="24">Item one</option>
<option value="29">Item Two<option>
<!--I have the first box going to 20 items-->
</select>
<p>Testing 2</p>
<select id="Test2">
<option value="25">Item one</option>
<option value="100">Item Two<option>
<!--I have the second box going to 10 items-->
</select>
<p>Testing 3</p>
<select id="Test3">
<option value="24">Item one</option>
<option value="100">Item Two<option>
<!--I have the third box going to 10 items-->
</select>
</form>
<button onclick="myFunction()">Update</button>
<p id="demo"></p>
그럼 난 내 자바 스크립트가
function myFunction()
{
var a = document.getElementById("list1");
var A = a.options[a.selectedIndex].value;
var b = document.getElementById("list2");
var B = b.options[a.selectedIndex].value;
var c = document.getElementById("list3");
var C = c.options[a.selectedIndex].value;
var IntA = parseInt(A);
var IntB = parseInt(B);
var IntC = parseInt(C);
var x=IntB + IntA;
var y=x + IntC;
var demoP=document.getElementById("demo")
demoP.innerHTML= y;
}
내 문제는 내가 완전히 우리의 c를 VAR을 다음 var에 y를 꺼내하고 X로 계산이있는 경우에만 작동합니다 있습니다. 나는 많은 tryed있다 길을 잃어 버렸어. 환호
P. 자바 스크립트는 하단의 스크립트 태그에 있습니다
... 일반적인 기능을 추출하여 반복해서 멈출 수 있습니다. – nzifnab
건배 난 롤에 넣어 후 이름을 알았어 난 그냥 예를 들어 지금 코드를 시도합니다 건배 – user2057440
건배 작품을 사용했다 :) – user2057440