0

this is my html and javascript coding. how to do contenteditable div onkeyup calculation. i tried it but i doesn't work...

        <td><div class="inputclass" id="quantity1" contenteditable> </div></td>
        <td><div class="inputclass" id="unitprice1" onkeyup="maths();" contenteditable> </div></td>
        <td><div class="inputclass" id="total1" contenteditable> </div></td>

function maths()
{
    var qt = document.getElementById("quantity1").value;
    var up = document.getElementById("unitprice1").value;
    qtup = parseFloat((qt * up)) || 0;
    document.getElementById("total1").value = qtup;
}

Edited by Indians

2
Contributors
3
Replies
9
Views
3 Years
Discussion Span
Last Post by minitauros
1

I haven't done this with editable <div>s before, but usually you get a div's content by using div.innerHTML, not div.value. So changing your code to

function maths()
{
    var qt = document.getElementById("quantity1").innerHTML;
    var up = document.getElementById("unitprice1").innerHTML;
    qtup = parseFloat((qt * up)) || 0;
    document.getElementById("total1").innerHTML = qtup;
}

might work. Why are you using editable <div>s instead of just inputs? :o

Edited by minitauros

0

got it. here i am using contenteditable for description column. so, i have the plan to use all rows 7c498ba6ffbce873cf7ac3a9a01fb9e2 in contenteditable..

0

Well I wouldn't know the downside of it right now, but it just feels somewhat off to me to use contenteditable divs for stuff that I usually use inputs and textareas for. Anyway, glad your problem has been solved ;).

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.