0

I am testing out a PowerPoint add-in and using the Office API to create some functionalities. One of them is taking input from the user (in a textarea tag), clicking a button that open a dialog box, and displaying the input as text in the box.

I attached an ID ('tarea') to the text area:

<textarea id="tarea" rows="2" cols="40"></textarea>

..and the button:

<button id="odi" class="ms-Button ms-Button--primary">
  <span class="ms-Button-label">Open Dialog</span>
</button>

..can read the value:

const query = document.getElementById('tarea').value

..and open the dialog box by pressing a button, a function that points to id=odi:

await Office.context.ui.displayDialogAsync('https://localhost:3000/test.html', {
    height: 70,
    width: 80,
    displayInIframe: true, 
}); 

How would I capture the value of the query and display it in the dialog box after pressing the button? The text area and button are in the taskpane folder, but the dialog box references another folder, test, which displays the content of test.html. So, ideally, I enter a query in the text area, press a button, clear the text area, and a dialog box displaying that query is shown.

Eugene Astafiev
  • 47,483
  • 3
  • 24
  • 45

1 Answers1

0

You can pass any parameters via URL and get the back on the dialog window using the window.location property which returns a Location object with information about the current location of the document.

Eugene Astafiev
  • 47,483
  • 3
  • 24
  • 45
  • Thank you. Do you know if there's a reference or example on how that could be done? Still new to this and failing at implementing it. – Iden Crisler May 01 '23 at 08:24
  • This is a widely spread web development practice, see https://livecodestream.dev/post/working-with-url-parameters-in-javascript/ for more information. – Eugene Astafiev May 01 '23 at 15:09