html - My javascript codes won't work? -
my html page codes :
<!doctype html> <html> <head><meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0"> <meta name="apple-mobile-web-app-capable" content="yes" /> <meta name="mobile-web-app-capable" content="yes" /> </head><link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=material+icons"> <link rel="stylesheet" href="https://code.getmdl.io/1.3.0/material.indigo-pink.min.css"> <script> function lengthconverter() { var inchref,inchtocmresultref; var inch,centimetres; inchref=document.getelementbyid("inchtocmvalue"); inchtocmresultref=document.getelementbyid("inchtocmresult"); inch=number(inchref.value); centimetres=number(inchtocmresultref.value) centimetres=2.54*inch inchtocmresultref.innertext=centimetres; } function lengthconvertercmtoinch() { var inch2ref,cmtoinchresultref; var inchtwo,centimetrestwo; inch2ref=document.getelementbyid("cmtoinchvalue"); cmtoinchresultref=document.getelementbyid("cmtoinchre"); inchtwo=number(inch2ref.value); centimetrestwo=number(cmtoinchresultref.value) inchtwo=centimetrestwo/2.54 cmtoinchresultref.innertext=inchtwo; } </script> <script defer src="https://code.getmdl.io/1.3.0/material.min.js"> </script> <body> <!-- shows header, in smaller screens. --> <div class="mdl-layout mdl-js-layout mdl-layout--fixed-header"> <header class="mdl-layout__header"> <div class="mdl-layout__header-row"> <!-- length --> <span class="mdl-layout-title">length</span> <!-- add spacer, align navigation right --> <div class="mdl-layout-spacer"></div> <!-- navigation. hide in small screens. --> <nav class="mdl-navigation mdl-layout--large-screen-only"> <a class="mdl-navigation__link" href="">length</a> <a class="mdl-navigation__link" href="mass.html">mass</a> </nav> </div> </header> <div class="mdl-layout__drawer"> <span class="mdl-layout-title">change conversion</span> <nav class="mdl-navigation"> <a class="mdl-navigation__link" href="">length</a> <a class="mdl-navigation__link" href="mass.html">mass</a> </nav> </div> <main class="mdl-layout__content"> <div class="page-content"><div class="mdl-grid"> <div class="mdl-cell mdl-cell--4-col"><h3>centimetres inches</h3> <!-- numeric textfield floating label --> <form action="#"> <div class="mdl-textfield mdl-js-textfield mdl-textfield--floating-label"> <input class="mdl-textfield__input" type="text" pattern="-?[0-9]*(\.[0-9]+)?" id="cmtoinchvalue"> <label class="mdl-textfield__label" for="cmtoinchvalue">centimetres...</label> <span class="mdl-textfield__error">input not number!</span> </div> </form> <!-- raised button ripple --><h4>inches:</h4> <span id="cmtoinchre"></span><button class="mdl-button mdl-js-button mdl-button--raised mdl-js-ripple-effect" onclick="lengthconvertercmtoinch()">convert inches</button> </div> <div class="mdl-cell mdl-cell--4-col"><h3>inches centimetres</h3> <!-- numeric textfield floating label --> <form action="#"> <div class="mdl-textfield mdl-js-textfield mdl-textfield--floating-label"> <input class="mdl-textfield__input" type="text" pattern="-?[0-9]*(\.[0-9]+)?" id="inchtocmvalue"> <label class="mdl-textfield__label" for="inchtocmvalue">inches...</label> <span class="mdl-textfield__error">input not number!</span> </div> </form> <!-- raised button ripple --><h4>centimetres:</h4> <span id="inchtocmresult"></span> <button onclick="lengthconverter()" class="mdl-button mdl-js-button mdl-button--raised mdl-js-ripple-effect">convert centimetres</button> </div> </div> </div> </main> </div> </body> </html>
i know it's long piece of code can't find mistake?
i copied codes material design lite(mdl)website interface create webpage convert cm inches , vice versa , links webpage mass making minor changes code.
i input converting function , onclick function myself.
but right side of webpage works while left column returns null?help appreciated.
i changed code in "lengthconvertercmtoinch()" observe here added 1 variable
function lengthconvertercmtoinch() { var inch2ref,cmtoinchresultref; var inchtwo,centimetrestwo,inchtwo1; inch2ref=document.getelementbyid("cmtoinchvalue"); cmtoinchresultref=document.getelementbyid("cmtoinchre"); inchtwo=number(inch2ref.value); centimetrestwo=number(cmtoinchresultref.value) inchtwo1=inchtwo/2.54 cmtoinchresultref.innertext=inchtwo1; }
i think problem has resolved
let me know if problem solved
Comments
Post a Comment