23 December 2010

how to get input value using javascript

javascript
Using only javascript and html,  we can get data from input box. using
document.getElementById('web').value
where, web = id of the input text box.

Sample code that use javascript to get input value:

[Note : Paste this code inside the <body> tag. to work.]

<script type="text/javascript">
function visit()
{
    var t = document.getElementById('web').value ;
    alert( t );
   
}
</script>

Enter Web Address: <input type="text" name="web" id="web"/>
<input type="button" value="Show what is in this Text Box" onclick='show();'/>


(If you found this article useful then share with your friends.)

No comments: