problem with my javascript function in MVC3 view

0

hello community stack I need help with my javascript function does not do the multiplication of text fields.

//funcion para multiplicar dos campos de texto
<script type="text/javascript">
    function multiplicar() {
        m1 = document.getElementById("Text1").value;
        m2 = document.getElementById("Text2").value;
        r = m1 * m2;
        document.getElementById("idtot").value = r;
    }
</script>
<div class="editor-label">
    @Html.LabelFor(model => model.qtyot)
</div>
<div class="editor-field">
    @Html.EditorFor(model => model.qtyot, new { @id = "Text1", @onchange = "multiplicar();" })
    @Html.ValidationMessageFor(model => model.qtyot)
 </div>
 <div class="editor-label">
    @Html.LabelFor(model => model.aot)
</div>
<div class="editor-field">
    @Html.EditorFor(model => model.aot, new { @id = "Text2", @onchange = "multiplicar();" })
    @Html.ValidationMessageFor(model => model.aot)
</div>
<div class="editor-label">
    @Html.LabelFor(model => model.tot)
</div>
<div class="editor-field2">
    @Html.EditorFor(model => model.tot, new { @id = "idtot" })
    @Html.ValidationMessageFor(model => model.tot)
</div>
    
asked by Hlvr 04.11.2016 в 20:19
source

1 answer

1

The EditorFor can not be given html attributes you must declare

@Html.TextBoxForModel(x => x.qtyot, new { @id = "Text1",  @onchange = "multiplicar();"})

Where x=> x.qtyot is the model of your EditorFor

    
answered by 04.11.2016 / 21:05
source