Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 07-23-2011, 11:56 AM   PM User | #1
jonjo
New to the CF scene

 
Join Date: Jul 2011
Posts: 6
Thanks: 2
Thanked 0 Times in 0 Posts
jonjo is an unknown quantity at this point
javascript get value of input field

I'm new in web-development. I've searched it but it's not found. I make a input then how i get value of it for javascript value?

Last edited by jonjo; 07-23-2011 at 12:54 PM..
jonjo is offline   Reply With Quote
Old 07-23-2011, 12:16 PM   PM User | #2
Philip M
Supreme Master coder!

 
Philip M's Avatar
 
Join Date: Jun 2002
Location: London, England
Posts: 17,103
Thanks: 197
Thanked 2,421 Times in 2,399 Posts
Philip M has a spectacular aura aboutPhilip M has a spectacular aura aboutPhilip M has a spectacular aura about
This is pretty fundamenatal and ought to be covered in any textbook. Assuming that your input is a textbox:-

Code:
<input type = "text" id = "txt1">
<br>
<input type = "button" value = "Click to get value entered into textbox" onclick = "getValue()">

<script type = "text/javascript">
function getValue() {
var val = document.getElementById("txt1").value;
alert (val);
}

</script>
The function can of course be called in different ways.


All this talk about ripping people's heads off - that going below the belt, really. - Presenter, BBC Radio 5 Live
__________________

All the code given in this post has been tested and is intended to address the question asked.
Unless stated otherwise it is not just a demonstration.
Philip M is offline   Reply With Quote
Users who have thanked Philip M for this post:
jonjo (07-23-2011)
Old 07-23-2011, 12:27 PM   PM User | #3
jonjo
New to the CF scene

 
Join Date: Jul 2011
Posts: 6
Thanks: 2
Thanked 0 Times in 0 Posts
jonjo is an unknown quantity at this point
sure, Is ".value" used for only numbers?
jonjo is offline   Reply With Quote
Old 07-23-2011, 02:48 PM   PM User | #4
xelawho
Senior Coder

 
xelawho's Avatar
 
Join Date: Nov 2010
Posts: 2,461
Thanks: 52
Thanked 457 Times in 455 Posts
xelawho will become famous soon enoughxelawho will become famous soon enough
Quote:
Originally Posted by jonjo
sure, Is ".value" used for only numbers?
it probably took you twice as long to type that question as it would have to test it yourself
xelawho is offline   Reply With Quote
Reply

Bookmarks

Tags
beginner, html, javascript

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 12:21 AM.


Advertisement
Log in to turn off these ads.