powlo
powlo

Reputation: 2688

AMP How to get event.valueAsNumber for select

I want to get a <select> value and assign it to an amp-state.

In theory I should be able to do event.valueAsNumber as documented here.

However I get "null" back when attempting to use this property.

Codepen.

Upvotes: 1

Views: 381

Answers (1)

Sebastian Benz
Sebastian Benz

Reputation: 4288

This looks like a bug as event.valueAsNumber should work. A workaround is to manually convert the value to an integer using the unary + operator:

 <select on="change:AMP.setState({product: {quantity: +event.value}})">

I've filed a bug here.

Upvotes: 3

Related Questions