html+css+java질문좀부탁드립니다.

조회수 471회
<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width">
    <title>자동견적시스템</title>
    <link href="style.css" rel="stylesheet" type="text/css" />
  </head>
  <style type ="text/css">
  .title{
    height:100px;
    border-bottom:2px solid black;
    display: flex;
    flex-direction: row;
    justify-content: center;
    align-items: center;
  }
  .prodName{
    display: inline-block;
    margin-right: 10px;
    font-family: "Noto Sans Bold";
    font-size: 42px;
    color: #222;
    line-height: 100%;
  }
  .tit0{
    float: left;
    position: relative;
    margin-top: 10px;
    margin-left: 10px;
    line-height:2.3em;
  }
/*테이블 셋팅*/
table.type02 {
    border-collapse: separate;
    border-spacing: 0;
    text-align: left;
    line-height: 1.5;
    border-top: 1px solid #ccc;
    border-left: 1px solid #ccc;
  margin : 20px 10px;
}
table.type02 th {
    width: 150px;
    padding: 10px;
    font-weight: bold;
    vertical-align: top;
    border-right: 1px solid #ccc;
    border-bottom: 1px solid #ccc;
    border-top: 1px solid #fff;
    border-left: 1px solid #fff;
    background: #eee;
    text-align: center;/*택스트중앙*/
}
table.type02 td {
    width: 150px;
    padding: 10px;
    vertical-align: top;
    border-right: 1px solid #ccc;
    border-bottom: 1px solid #ccc;
    text-align: center;
}
  </style>
  <script>
function multiplyBy()
{
        num1 = document.getElementById("firstNumber").value;
        num2 = document.getElementById("secondNumber").value;
        document.getElementById("result").innerHTML = num1 * num2;
        document.getElementById("result2").innerHTML = num1 * num2;

        /*곱*/
        num3 = document.getElementById("result1").value;
        document.getElementById("result3").innerHTML = num3 * num1 * num2;

}
    </script>
  <body>
    <div class="title">
      <h3 class="prodName" id="subTitleProdNm">견적서</h3>     
    </div>
    <div class="tit0">
                        <h4>종류 선택</h4>
               <form>
                칸수 <input type="number" id="firstNumber"/><br> 줄수 <input type="number" id="secondNumber"/><br>
                <input type="button" onClick="multiplyBy()" Value="합계" /> = 
               <span id ="result"> 결과값 </span>
                </form>
<table class="type02">
    <tr>
        <th scope="col">품명</th>
        <th scope="col">가격</th>
        <th scope="col">수량</th>
        <th scope="col">합계</th>
    </tr>
    <tr>
      <th scope="row"> 사과</th>
      <td id="result1">500</td>
      <td id="result2"></td>
      <td id="result3"></td>
</table>
                </div>



  </body>
</html>



칸수 * 줄수 하면 합계가나오고

가격 X 수량 = 합계 가 되어야되는데

가격 500이 정수가아닌지 곱샘이 안되는데

      <td id="result1">500</td> 
num3 = document.getElementById("result1").value;

이거 어떻게 처리하면 될까요?

  • parseInt(document.getElementById("result1").innerText) 엽토군 2019.11.1 17:39
  • ㅠㅠ 저렇게해도 NaN으로결과값떠영 알 수 없는 사용자 2019.11.2 09:10
  • 해당 코드는 브라우저 이슈도 딱히 없는 코드인데,,, 페이지가 갱신되지 않은건 아닐까요? 엽토님이 달아주신 방법으로 해결이 됩니다;;; 알 수 없는 사용자 2020.1.3 20:12

답변을 하려면 로그인이 필요합니다.

프로그래머스 커뮤니티는 개발자들을 위한 Q&A 서비스입니다. 로그인해야 답변을 작성하실 수 있습니다.

(ಠ_ಠ)
(ಠ‿ಠ)