Hi,
I’m afraid that we cannot debug your entire code…
I recommend checking out our Messaging article to better understand how the iFrame component sends & gets information from the page code. I recommend using only one postMessage on the onReady function and another one on the input change event. Moreover, I recommend checking out our Charts example.
Good luck,
Tal.