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

Plot No. 64, PU-4, Scheme 54, Behind C21 Mall near Hotel Holiday , AB Road, Indore Pin-code:452001

Email Us

contact@codebetter.in

Call Us

+91 88230 75444, +91 99939 28766

Loading
Your message has been sent. Thank you!