JavaScript Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsWeb DesignJavaScript Development

Closed Thread
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old March 24th, 2007, 10:54 AM
alicats12345 alicats12345 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2007
Posts: 67 alicats12345 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 15 h 51 m 40 sec
Reputation Power: 7
Get text string from div

i am trying to create a search indexer for my site. but i use php to include the menus and header on every page, so it automatically adds links from those to the index db. i am trying to use javascript to get all the text from a div i specify using id's. the following code gives me an error message:
'd has no properties'
Code:
function getText(divname)
{
  d=document.getElementById(divname);
  return d.value;
}

what can i do instead to get all the text from a div?

Reply With Quote
  #2  
Old March 24th, 2007, 11:00 AM
huyaroo's Avatar
huyaroo huyaroo is offline
:)
Dev Shed Intermediate (1500 - 1999 posts)
 
Join Date: Oct 2006
Location: IL
Posts: 1,520 huyaroo User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)huyaroo User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)huyaroo User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)huyaroo User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)huyaroo User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)huyaroo User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)huyaroo User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)huyaroo User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)huyaroo User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)huyaroo User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)huyaroo User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)  Folding Points: 303 Folding Title: Novice Folder
Time spent in forums: 2 Weeks 6 Days 3 h 14 m 13 sec
Reputation Power: 439
The value property only works if you are working with form fields. Use innerHTML instead. It would be return d.innerHTML;
__________________



shinygears | twinarrow

Reply With Quote
  #3  
Old March 24th, 2007, 01:47 PM
alicats12345 alicats12345 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2007
Posts: 67 alicats12345 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 15 h 51 m 40 sec
Reputation Power: 7
Quote:
Originally Posted by huyaroo
The value property only works if you are working with form fields. Use innerHTML instead. It would be return d.innerHTML;

i am using firefox 2 and have tried what you said.
i just get an document.getElementById(divname) has no properties.
Code:
function getText(divname)
{
	var html = document.getElementById(divname).innerHtml;
	return html;
}

Reply With Quote
  #4  
Old March 25th, 2007, 07:57 AM
alicats12345 alicats12345 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2007
Posts: 67 alicats12345 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 15 h 51 m 40 sec
Reputation Power: 7
Quote:
Originally Posted by alicats12345
i am using firefox 2 and have tried what you said.
i just get an document.getElementById(divname) has no properties.
Code:
function getText(divname)
{
	var html = document.getElementById(divname).innerHtml;
	return html;
}

i have sorted this out. i had a syntax problem

Reply With Quote
Closed Thread

Viewing: Dev Shed ForumsWeb DesignJavaScript Development > Get text string from div

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap