Reputation: 21
Im having trouble with the following code. Here is the html part
<form name="convert">
Choose which currency you would like to convert the Euro to:
<select id="conversionType">
<option value="polish">Polish Zloty</option>
<option value="ukraine">Ukraine Hryvnia</option>
</select>
</br>
</br>
<hr>
Amount:<input id="amount" type="text" />
<input id="convertButton" type="button" value="Convert->"/>
To:
<input id="answer" type="text" name="answer" readonly="readonly"/>
</form>
and here is the javascript code. it has been changed and helped before but i cannot see why it is not working
window.onload = initPage;
var euro;
var convert;
function initPage()
{
document.getElementById("convertButton").onclick = calcAnswer;
document.getElementById("conversionType").onchange = calcAnswer;
}
function calcAnswer()
{
//alert(document.getElementById("conversionType").value);
var value1 = document.getElementById("amount").value1;
var conversionType = document.getElementById("conversionType").value1;
//alert(conversionType);
//if(var value = document.getElementById("conversionType").value=="polish");
// document.getElementById("answer").value=value1 * 4.4976;
//else
// document.getElementById("answer").value=value1* 10.43958;
if(conversionType == "polish") {
document.getElementById("answer").value1=value1 * 4.4976;
} else {
document.getElementById("answer").value1=value1 * 10.43958;
}
}
it will not work at all. i dont know why because i think that the theory is sound. any help wpuld be much appreciated
Upvotes: 1
Views: 3739
Reputation:
Shouldn't this
<pre> document.getElementById("answer").value1 </pre>
be
document.getElementById("answer").value = value1 * 4.4976
Upvotes: 0
Reputation: 18833
Any time you do this:
document.getElementById("amount").value1
should be this:
document.getElementById("amount").value
no such thing as value1.
Upvotes: 1