AMP: Accessing input values on tap without submitting a form

Viewed 53

I got the following setup:

<input type="text" name="mdate" value="">

<select name="cycle">
   <option value="1">1</option>
   <option value="2">2</option>
</select>

<button type="button">Calculate</button>

<amp-date-picker
    [src]="'https://example.com/api/calculate/?cycle=' + cycle + '&mdate=' + mdate">
</amp-date-picker>

I need to pass the both input values into the URL in the amp-date-picker.

Now if I do it with on="change:AMP.setState(...)" in <input> and <select>, the request from [src] is triggered before I have filled my both parameters.

I tried using a variable in a pre-defined state, which gets updated on tap on the button and gets inserted in the [src]. But as soon as the input - and therefore the state - is changed, the request still gets triggered too early, before the button action.

0 Answers
Related