0
変換の計算が正しく行われていますが(高さがcmで表示されている要素から値を取得してからft /右側のスパンが機能しない(クリックすると)それを表示すると、参照エラー(コンバータが定義されていません)が表示されます。ft値にCmを取得して他の要素に表示すると参照エラーが発生する
なぜそれが定義されていないのか、それが吊り上げによるものなのか、parseInt関数のパラメータがそのままであるのか分かりません。ここで
はリンク機能ここvar displayInches = document.getElementById("heightInches");
displayInches.addEventListener("click", function() {
toFeet(converter);
});
function toFeet(converter) {
var heightOutputCM = document.getElementById("yourHeight");
var converter = parseInt(heightOutputCM.value);
var realFeet = converter * 0.3937/12;
var feet = Math.floor(realFeet);
var inches = Math.round((realFeet - feet) * 12);
return feet + "and" + inches;
}
されている。
https://codepen.io/damianocel/pen/ZyRogX
ありがとうございますが、動作しません。 このビットはproblemtaicのようです: var converter = parseInt(heightOutputCM.value); – ptts
変換した値をどこにでも表示したいですか? – Vineesh
はい、デフォルトの「ft」の右スパン要素です。クリック時。または、左のスパン要素の永続的な更新などがさらに優れています。 – ptts