I'm trying to get the text value and the link to change depending on which radio button is selected. For example, selecting the first radio button would change the text to "Google" and it would link to google.com. While selecting the second radio button would change the text to "bing" and link to bing.com. I have managed to get the text to change, however the link is not working correctly. Any help would be appreciated.
jsfiddle - https://jsfiddle.net/3yrcusv8/
$('.radiogroup').change(function(e){
var selectedValue = $(this).val();
$('#amount').val(selectedValue)
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<input type="radio" name="radiogroup" id="radiogroup1" class="radiogroup" value="Google" />
<input type="radio" name="radiogroup" id="radiogroup2" class="radiogroup" value="Bing" />
<input type="submit" name="amount" id="amount" onclick='myFunction()' />
<script>
function myFunction() {
if(document.getElementById('radiogroup1').checked) {
document.getElementById('amount').href = "https://google.com";
}
}
</script>