exam 1

by chris richarde

HTML

<input type="textbox" id="string" />
<input type="button" id="stack" value="convert" onClick="convertMe();" />
<p id="answer"></p><br>

JavaScript

function convertMe()
      {
        var converted = stringToAscii(document.getElementById('string').value);
        document.getElementById('answer').innerHTML = converted;
      }

      function stringToAscii(s)
      {
        var ascii="";
        if(s.length>0)
          for(i=0; i<s.length; i++)
          {
            var c = ""+s.charCodeAt(i);
            while(c.length < 3)
              c = "0"+c;
            ascii += c;
          }
        return(ascii);
      }