Click here to Skip to main content
15,886,873 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
There is an XHTML form including 3 text boxes and a submit button.
When the submit button is pressed the data in the text boxes must be submitted and they should identified by JavaScript and should pass those variable values to an alert!

How could I able to do that!
Posted
Updated 29-Oct-11 4:53am
v2
Comments
Uday P.Singh 29-Oct-11 12:09pm    
you could have googled it first.

1 solution

When you say submit, you imply you are sending the values back to the server. If you want to use JavaScript to get the values out form fields and present them in an alert, this is what you might do:

HTML
<html>
<script>
function showValues() 
{
    alert(document.getElementById('txtMgs').value);
}
</script>

<body><form>

<input type="text" id="txtMsg" />
<input type="button" value="click me!" id="btnRun" onclick="showValues();" />

</form></body></html>
 
Share this answer
 
Comments
Chiranthaka Sampath 29-Oct-11 11:08am    
Thanks a lot!
Uday P.Singh 29-Oct-11 12:09pm    
simple 5!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900