I have been trying to get a simple JS function to work for the longest while but its just not working. Console says "test is not a function.
echo '<input type="hidden" value="'.$return_survey_url.'" id="return_url">';
echo '<form action="http://www.example.com/test.php" onsubmit="return test();" method="post" target="votar">';
echo '<textarea name="tweet" rows="8" cols="10" maxlength="130"></textarea>';
echo '<input type="submit" value="test"/>';
echo '<iframe name="votar" style="display:block; width: 500px; height: 500px;"></iframe>';
echo '</form>';
The below that I close the PHP tag and have a simple script:
<script type="text/javascript">
function test() {
alert('thank you');
var return_url = document.getElementById('return_url').value;
window.location.href= return_url;
}
</script>
Whenever I click the submit button console spits out that it is not a function. I am trying to get this to work within a CPT template, this code only needs to happen on that specific template. This same code works here: