none
Can we get user input in an Office.js Add-in? RRS feed

  • Question

  • In task pane of our Office.js WORD add-in, we need to get a user input and display in the document. Is it even possible to get user input in an Office.js add-in. If so, is there any Office.js API for that?
    Wednesday, October 17, 2018 4:06 AM

Answers

  • Hi namwam,

    >>get user input in an Office.js Add-in?

    Please try the code as below:

    //write a input with id='input1' on the page
    <input type="text" id="input1" />
    
    // Function that writes to a div with id='message' on the page.
    function write(message){
        var text = document.getElementById('input1').value;
        document.getElementById('message').innerText = text; 
    }

    Hopefully it helps you.

    Best Regards,

    Lina


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread.

    • Marked as answer by namwam Wednesday, October 17, 2018 7:07 PM
    Wednesday, October 17, 2018 5:27 AM

All replies

  • Hi namwam,

    >>get user input in an Office.js Add-in?

    Please try the code as below:

    //write a input with id='input1' on the page
    <input type="text" id="input1" />
    
    // Function that writes to a div with id='message' on the page.
    function write(message){
        var text = document.getElementById('input1').value;
        document.getElementById('message').innerText = text; 
    }

    Hopefully it helps you.

    Best Regards,

    Lina


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread.

    • Marked as answer by namwam Wednesday, October 17, 2018 7:07 PM
    Wednesday, October 17, 2018 5:27 AM
  • Hi Lina,

    Excellent. Thank you.
     I've posted another Office.js question here in case you have any insight on it.


    • Edited by namwam Wednesday, October 17, 2018 7:20 PM
    Wednesday, October 17, 2018 7:08 PM