inserting into text elements

inserting into text elements

hello guys and ladies,

I am completly new to the topic, learning about dom right now and I think I don“t get somethink... Suppose I have this form:

<body>

    <form action="index.php" method="POST">
        
        <input type="text" name="string">
        
    </form>

</body>


and I have a function which does something and in the end of the function I just want to insert a value which is counted by the function into the text... I am trying something like:

$('#string').val($vysledny_text);
$("#string").append($vysledny_text);

so in the end I want to have:



and of course nothing seems to be working... Can you please help me with this?