Skip to content

Instantly share code, notes, and snippets.

@sam452
Last active August 29, 2015 14:25
Show Gist options
  • Save sam452/737bdf0990b1af0ef203 to your computer and use it in GitHub Desktop.
Save sam452/737bdf0990b1af0ef203 to your computer and use it in GitHub Desktop.
pass output of js function into PHP form
<form method="post" action="confirmation.php" name="donationForm" id="donationForm" onsubmit="return validateAmount();">
<input type="hidden" id=
"my-frequency" name="frequency" value=
<?php echo '<script type="text/javascript"> myLastFrequency(); </script>'; ?>
/>
<button class="new-look-select-color new-look-submit-btn" data-pointer-submit="true" name="sbmit" type="submit" value="Submit">SUBMIT
</button>
function myLastFrequency() {
lastFrequency = document.getElementsByClassName('active btn btn-frequency-custom');
if (lastFrequency.length == 1) {
return lastFrequency[0].getAttribute('data-freq');
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment