I'm carrently building a website to host my music live stream. I made a section where people can suggest songs and the suggestions are stored in an SQL Database. I want the Submit button on this form to change when submitting from "Submit Recommendation" to "Thank you" when clicked but also for a client to be able to press it once to avoid flooding. Well i haven't managed to make these work together (and keep the required attribute on my tags) but I have managed to do them one at a time. This is my code please help!
<form action="./add.php" method="POST" target="sendFormSuggest" onsubmit="return checkBeforeSubmit() ">
<!--The form for suggestions -->
Song: <span style="color: red">* </span>
<input class="recom" type="text" name="song" size="50" required><br>
Artist: <span style="color: red">* </span>
<input class="recom" type="text" name="artist" size="50" required><br>
YouTube Link:
<input class="recom" type="text" name="link" size="50"><br>
<input class="Submit" type="submit" value="Submit Recommendation" id="ButtonRecom">
</form>
<script type="text/javascript"> <!--this checks the any form for second submition -->
var wasSubmitted = false;
function checkBeforeSubmit() {
if (!wasSubmitted) {
wasSubmitted = true;
return wasSubmitted;
document.getElementById("ButtonRecom").value = "Thank you!";
}
return false;
}
</script>
return wasSubmitted;statement before changing button value. Prepend value change before return statement and it works.