I have a question on as why my code won’t execute correctly, I need to be as basic as possible when applying these commands. I hit the convert button and nothing, did I need a command for that too? It is for homework, I have been dabbling at it for hours.
EDIT***
<html>
<head>
<script type="text/javascript">
<script>
function Convert()
onclick= document.getElementById('Convert')
var years = document.getElementById("year").value;
var days = document.getElementById("days").365.25 * years;
var hours = document.getElementById("hours").(365.25 * 24) * years;
var minutes = document.getElementById("minutes").(365.25 * 24 * 60) * years;
var seconds = document.getElementById("seconds").(365.25 * 24 * 60 * 60) * years;
document.getElementById('days').value = days;
document.getElementById('hours').value = hours;
document.getElementById('minutes').value = minutes;
document.getElementById('seconds').value = seconds;
});
</script>
</head>
<body>
Years: <input type='text' id='years' />
<button id='Convert'onclick= "Convert()" value= "Convert"/> Convert </button>
Days: <input type='text' id='days' />
Hours: <input type='text' id='hours' />
Minutes: <input type='text' id='minutes' />
Seconds: <input type='text' id='seconds' />
</body>
</html>
A few things (hopefully they get you going again):
onClickhandler to your button.prompting fixed strings instead of variables.inputin your JavaScript. You could usedocument.getElementById()for that.Note, I could give you the answer, but homework and learning is all about figuring stuff out by yourself. Get going with my tips and see what you can come up with. Edit your question with what you got if you get stuck again.
Okay, next round. What you’ll have to do in your
Convertfunction:First, fetch the information from the form like this:
Then, do you calculations:
Finally, write back the results:
Some extra tips:
id='Convert'andonclickGood luck!
Round three; here is the complete answer. Just try to understand what is going on. It is usually good to learn from working examples.
Extra stuff I found:
<script>tag in your htmlfunction foo() { }—— complete answer follows —–