JavaScript > Assignment Operators

Multiply and assign in JavaScript

How to multiply and assign value in JavaScript?

To multiply and assign value in JavaScript, we can follow this approach.

        function Multiplyassignvalue() {
            var a = document.getElementById("txtA").value;
            var result = 5;
            result *= parseInt(a);

    Enter two digit:
    <input type="text" id="txtA" name="txtA" />
    <input type="button" name="btnMultiplyassignvalue" value="Multiply & Assign value"
        onclick="Multiplyassignvalue()" />

In the above code snippet, we have one textbox. On click of button, we are calling the Multiplyassignvaluefunction that multiply and assign the number and show result in the alert. Here also parseInt() is parsing the string to integer and multiplying to 5.


 Views: 817 | Post Order: 21

Write for us