JavaScript Practice Questions And Answer

Problem: Write a program to find gross salary (Hint :-GS=BS+DA+TA).
Solution:
            <html>
             <head>
              <script>
                function findGS()
              {
                var bsBox = document.getElementById("input1")
                var bs = parseInt(bsBox.value)
                var taBox = document.getElementById("input2")
                var ta = parseInt(taBox.value)
                var daBox = document.getElementById("input3")
                var da = parseInt(daBox.value)
                var gs = bs + ta + da
                var resultBox = document.getElementById("result")
                resultBox.innerHTML = "Gross Salary = " + gs    
              }
               </script>
              </head>
               <body>
                <input type="text" placeholder="Basic Salary" id="input1"/>
                <br>
                <input type="text" placeholder="TA" id="input2"/>
                <br>
                <input type="text" placeholder="DA" id="input3"/>
                <br>
                <input type="button" value="Find GS" onclick="findGS()"/>
                <div id="result">
                  GS = 0
                </div>
               </body>
             </html>
          

Contact Us

Our Address

Office no.- 401,Shekhar Central Building ,Palasiya, Pin-code:452001, Indore

Email Us

contact@codebetter.in

Call Us

+91 88230 75444, +91 99939 28766

Loading
Your message has been sent. Thank you!