下面是我的缩短代码。我需要在Javascript代码中运行PHP for循环,但不确定是否正确。在for循环中,我需要生成一些HTML代码。
<script>
window.addEventListener('load', async () => {
....
....
....
<?php $i = 0; ?>
<?php foreach ($vendor_items as $item):
....
....
....
echo '<tr><td><button class="sendButton'. $i . '">Send</button></td></tr>';
?>
...
...
listenForClicks(recipientAddress<?php echo $i; ?>, smartContract, web3, tokenId<?php echo $i; ?>);
<?php endforeach; ?>
});
</script>