Passing a HTML DOM Property In an input - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Form Event

Description

Passing a HTML DOM Property In an input

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
   </head> 
   <body> 
      <input type="text" onkeyup="myFunction(this.value)"> 
      <p id="message"></p> 
      <script type="text/javascript">
function myFunction(propName) {/*from w w w  .j a  va 2 s.c  om*/
  var p = document.getElementById("message");
  try {
    p.innerHTML = eval(propName);
  } catch(e) {
    p.innerHTML = "invalid";
  }
}

      </script>  
   </body>
</html>

Related Tutorials