How do access the data a user types into a Text Input box?

Hi, I added an input text box, a button, and a header on the page. When a user enteres in some data and clicks a button I want that data to be displayed on the screen.

I wrote this code but it doesn’t work. When type something into the box and click the button, the header just changes to “text”.

$w.onReady(function () {

   let TestInput1 = $w("#input1").inputType;
   $w('#button1').onClick (() => {
      $w('#text1').text = TestInput1;
   });
   
});

Could somebody fix my test code for me? Thanks.

@wefilmit , the let statement runs just after the page loads, so the value of TestInput1 is captured at that point in time and not when the user clicks the button. Moving that line in with the onClick code will solve the problem.

$w.onReady(function({
   $w('#button1').onClick(()=>{
      let TestInput1 = $w("#input1").inputType;
      $w('#text1').text = TestInput1;
   });
});

Thank you.