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

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 03-24-2009, 09:53 AM   PM User | #1
vkdixit
New Coder

 
Join Date: Nov 2008
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
vkdixit is an unknown quantity at this point
How we fetch the value of textarea in prototype.js

Hi all,
I am using prototype js. I have fetch the value of textbox here, but right now unable to fetch the value of textarea....

I am doing like below:

<script language="javascript" type="text/javascript">

var comm = document.post_comm.comment.value;

alert(comm);

</script>

<textarea cols="80" rows="10" class="tb" id="comment" name="comment"></textarea>



But i am getting null value here....

after that i used (var comm = $('comment')
it gives us some alert like: ([object HTMLTextAreaElement])


plz help
vkdixit is offline   Reply With Quote
Old 03-24-2009, 03:15 PM   PM User | #2
Eldarrion
Regular Coder

 
Join Date: Feb 2009
Location: Wheeling, IL
Posts: 358
Thanks: 5
Thanked 62 Times in 60 Posts
Eldarrion is on a distinguished road
Or an even simpler way to do it, considering you have an id:

Code:
	var comm = document.getElementById("comment").value;
	alert(comm);
Definitely does the trick. Of course, if you are using jQuery...

Code:
var comm = $('comment')
Would certainly return an object, considering what that does is... select element by name... at least from the looks of it, as opposed to getting the value of that element. All in all, if that's the only textarea in the document and you want to achieve the same result without getting by id...

Code:
	var comm = document.getElementsByTagName("textarea");
	var comm = comm[0].value;
	alert(comm);
I'm sure there's at least a couple of other ways to do this thing, but eh... I'm not going to go through them all. Your original issue seems to come from a wrong reference to an object though. So if you don't want to use either of the shown results, look into that.
__________________
The way to success is to assume that there are no impossible things. After all, if you think something is impossible, you will not even try to do it.

How to ask smart questions?
Eldarrion is offline   Reply With Quote
Old 03-25-2009, 02:58 PM   PM User | #3
ohgod
Regular Coder

 
ohgod's Avatar
 
Join Date: Jun 2008
Location: Ohio
Posts: 579
Thanks: 6
Thanked 69 Times in 69 Posts
ohgod is on a distinguished road
you can access any form element's value with $F('id')

http://www.prototypejs.org/api/utility/dollar-f
ohgod is offline   Reply With Quote
Old 04-06-2009, 01:47 PM   PM User | #4
vkdixit
New Coder

 
Join Date: Nov 2008
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
vkdixit is an unknown quantity at this point
Thankx to all////
vkdixit is offline   Reply With Quote
Reply

Bookmarks

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 04:21 AM.


Advertisement
Log in to turn off these ads.