The product page form id refers to a string
product-buttons-form-template--21902126481726__main
which can’t be converted to a number.
Whereas on fast add it refers to an input field which holds the numeric value of the variant:
input#formVariantId

