{"id":12596926,"date":"2020-03-29T07:09:01","date_gmt":"2020-03-29T07:09:01","guid":{"rendered":"https:\/\/wordpress.org\/support\/topic\/amp-script-problem\/"},"modified":"2020-03-29T07:09:01","modified_gmt":"2020-03-29T07:09:01","slug":"amp-script-problem","status":"publish","type":"topic","link":"https:\/\/wordpress.org\/support\/topic\/amp-script-problem\/","title":{"rendered":"amp-script problem"},"content":{"rendered":"<p>i&#8217;m having problem with the amp-script implementation.<br \/>\nthe code below has 2 checkboxes which are generated within a loop as the groups which each checkbox belong to (the ids) are taken from the loop.<\/p>\n<p><code>&lt;input type=&quot;checkbox&quot; name=&quot;group1[]&quot; on=&quot;tap:AMP.setState({ crox: ((crox != &#039;123&#039;) ? &#039;123&#039; : &#039;123&#039;)}),croxform.submit&quot; \/&gt;<\/code><br \/>\n<code>&lt;input type=&quot;checkbox&quot; name=&quot;group2[]&quot; &quot;tap:AMP.setState({ crox: ((crox != &#039;{256&#039;) ? &#039;256&#039; : &#039;256&#039;)}),croxform.submit&quot; \/&gt;<\/code><\/p>\n<p>On each page, 100 of these checkboxes are generated and group ids belong to categories and crox ids are post ids. when a checkbox is selected the post id is sent to the croxform. <\/p>\n<p>Now, before AMP, I was able to make sure that only 1 checkbox from a given group (either 1 or 2 or any other amount of groups) could be selected at any given time using the javascript code below<br \/>\n<code>$(&#039;input[type=&quot;checkbox&quot;]&#039;).on(&#039;change&#039;, function() {<\/code><br \/>\n<code>$(&#039;input[name=&quot;&#039; + this.name + &#039;&quot;]&#039;).not(this).prop(&#039;checked&#039;, false);<\/code><br \/>\n<code>});<\/code><\/p>\n<p>It&#8217;s a jquery script and i&#8217;m trying to use amp-script to apply the same method on an amp page. however, till now i have been unsuccessful on all my tries as I&#8217;ve gone through all the questions and answers on stackoverflow, google search. can someone help me out with the problem?<br \/>\nif anyone can think of a way, then is it possible to have on=&#8221;change:AMP.setState&#8221; to apply to this case?<\/p>\n","protected":false},"template":"","class_list":["post-12596926","topic","type-topic","status-publish","hentry","topic-tag-custom-javascript"],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/12596926","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic"}],"about":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/types\/topic"}],"version-history":[{"count":0,"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/12596926\/revisions"}],"wp:attachment":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/media?parent=12596926"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}