I am not very good at javascript but have messing around with it for a class project.
Here is my code right now:
HTML:
<form id="Resume_Select">
<input type="radio" name="resume_type" value="Economics" >Economics
<br />
<input type="radio" name="resume_type" value="MIS" >Management Information Systems
<br />
<button onClick="resume_select()"> Download</button>
</form>
Javascript:
<script>
function resume_select(){
var radios = document.getElementByName('resume_type');
for(var i = 0, length = radios.length; i<length;i++){
if(radios[i].checked){
var resume = radios[i].value;
alert(radios[i].value);
break;
}
}
</script>
When I select a radio button then click the download button, nothing happens. No alert shows up or anything.
I would greatly appreciate some input on how to improve this.
Other note, I know that it can be done easier with jQuery I have seen, but please stick to javascript. I want to learn jQuery, just not quite yet haha.
Thanks!
Aucun commentaire:
Enregistrer un commentaire