how to get the value of an control

来源:互联网 发布:qq翻译软件下载 编辑:程序博客网 时间:2024/04/29 09:02
 If a html page contains what likes:
<table>
        
<tr>
            
<td>
                Enter Key Here ->
                
<input type="text" id="key" name="key"
                       onkeyup
="convertToDecimal( );">

            
</td>
        
</tr>
    
</table>
    
<br />
    
<table>
        
<tr>
            
<td colspan="5" style="border-bottom:solid black 1px;">
                Key Pressed:
                
<input type="text" readonly id="keypressed">
            
</td>
        
</tr>
      </tabl

We can get keys using getElementById( keyId ),

var key = document.getElementById("key");

var keypressed = document.getElementById("keypressed");

And we can put the value of key into the value of keypressed like this:

keypressed.value = key.value;
So we can get the value of a <input> control by:
myvalue = document.getElementById("keyId").value;