I am trying to change some text based on a radio button selection using jQuery but I can't seem to get it working. This is my code as it stands:
HTML
<input type="radio" name="finish_id" id="1" value="1" checked />
<label for="1" id="veteran"></label>
<input type="radio" name="finish_id" id="2" value="2" />
<label for="2" id="elite"></label>
<input type="radio" name="finish_id" id="3" value="3" />
<label for="3" id="legendary"></label>
<span id="finish_name"></span>
JS
// Set variables
var finish[] = "something";
var finish[] = "something else";
var finish[] = "another thing";
// Change finish name based on radio selection
$(document).ready(function() {
$("input[name='finish_id']").change(function() {
$('#finish_name').text( finish[$(this).val()] );
}).change();
});
I'm probably way off with the array number being $(this).val(), I don't know if you can select it that way, but even if I set it to $('#finish_name').text( finish[1] ); I get an unexpected token [ error. How can I use the array value for .text()?