Search code examples
javascripthtmltextareajqmath

Convert HTML text area value to jqmath formula


I am new to jqmath; I have contained a textarea field in my HTML:

<textarea cols="30" rows="2" id="mathSrc1"></textarea>

I will set mathematical formula in the text area so that it will be displayed in <div> tag:

<div id="mathTgt1"></div>

This code is available in http://mathscribe.com/author/jqmath.html. But I don't know how to use it. Please help me.

Thank you.


Solution

  • i got solution

    <input type="textarea" name="formula" id="test_formula" onkeyup="paste_formula()" />
    <span id="formula_print"></span>
    

    script code

    function paste_formula() {
    var val = document.getElementById("test_formula").value;
    
    val = "$$" + val + "$$";
    var di = document.getElementById("formula_print");    
    
    di.innerHTML = val;
    M.parseMath(di);
    

    }