How to code a button so that when it is clicked on a certain value is stored, and then can be put in to a equation to make a prediction later on? Here is the JSfiddle link to what were working on, we are trying to code an application to predict ski injury and need some help!!!!!
http://jsfiddle.net/DYJkG/792/
Html:
<h1>Personal information</h1>
<h2>gear</h2>
<div class="toggle-btn-grp">
<label onclick="1" id="helmet" value="1" class="toggle-btn"><input type="radio" name="group2"/>helmet</label>
<label onclick="" class="toggle-btn"><input type="radio" name="group2"/>hat</label>
<label onclick="" class="toggle-btn"><input type="radio" name="group2"/>nothing</label>
</div>
<h2>ability</h2>
<div class="toggle-btn-grp">
<label onclick="" class="toggle-btn"><input type="radio" name="group2"/>beginner</label>
<label onclick="" class="toggle-btn"><input type="radio" name="group2"/>intermediate</label>
<label onclick="" class="toggle-btn"><input type="radio" name="group2"/>advanced</label>
</div>
<h2>snow conditions</h2>
<div class="toggle-btn-grp joint-toggle">
<label onclick="" class="toggle-btn"><input type="radio" name="group3"/>hard packed</label><label onclick="" class="toggle-btn"><input type="radio" name="group3"/>powder</label><label onclick="" class="toggle-btn"><input type="radio" name="group3"/>ice</label>
</div>
<h2>weather</h2>
<div class="toggle-btn-grp cssonly">
<div><input type="radio" name="group4"/><label onclick="" class="toggle-btn">clear</label></div>
<div><input type="radio" name="group4"/><label onclick="" class="toggle-btn">partly cloudy</label></div>
<div><input type="radio" name="group4"/><label onclick="" class="toggle-btn">snowy</label></div>
</div>
<!-- Note: empty onclick attribue is there to fix iOS labels not being clickable to their input target -->
<input type="button" id="button" value="Find your precentage!" />
<input type="button" id="button2" value="Learn more" />
Javascript:
$(".toggle-btn:not('.noscript') input[type=radio]").addClass("visuallyhidden");
$(".toggle-btn:not('.noscript') input[type=radio]").change(function() {
if( $(this).attr("name") ) {
$(this).parent().addClass("success").siblings().removeClass("success")
} else {
$(this).parent().toggleClass("success");
}
});
var onClick = function() {
alert("87%");
};
$('#button').click(onClick);
$('#button2').click(function() {
alert('I have literally no idea what you selected but you should probably stay off of they hill');
});