Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Web Programming > JavaScript > Javascript How-To
Javascript How-To Ask your "How do I do this with Javascript?" questions here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript How-To section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old July 27th, 2004, 09:11 AM
Friend of Wrox
Join Date: Sep 2003
Posts: 121
Thanks: 0
Thanked 0 Times in 0 Posts
Default Getting HTML element text using id


  i'm very new to JavaScript so dumb questions follow...

  1. is JSP and JScript and JavaScript all the same thing ?

  2. I have assigned a unique id to an HTML textarea.
     I then pass this id into a JavaScript function.
     I want to get the text from the textarea. I have tried
     using getElementById by it doesn't seem to work.


     In an HTML page

     function GetElement(id){
       var oElement;
       var sString;

       oElement = getElementById(id);
       sString = oElement.Text;

My aim to set sString to the text contained within the element
that has the id = 'id'. (In my case the element is a text area).
I cant find an example in my book.
Any syntax help please.

Old July 27th, 2004, 12:17 PM
Friend of Wrox
Join Date: Jun 2003
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts


JavaScript was created by sun, JScript is similar to JavaScript created by Microsoft, JSP is server-based, which means Java Server Pages.

You can get the element via document.getElementById(ID), and for a textarea, you may need to use innerText, or value. I'm not sure.


Similar Threads
Thread Thread Starter Forum Replies Last Post
remove duplicate text in an output html element mrame XSLT 1 June 20th, 2008 01:41 AM
html table row id myself.panku ASP.NET 1.x and 2.0 Application Design 0 April 17th, 2008 01:56 PM
value-of within the HTML element attribute BrendonMelville XSLT 1 March 14th, 2006 11:32 AM
html control with same id and name ??? muklee Javascript 1 October 22nd, 2004 12:49 AM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.