Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 1.0 and 1.1 > ASP.NET 1.1
|
ASP.NET 1.1 As of 10/6/2005, this forum is locked as part of the reorganization described here: http://p2p.wrox.com/topic.asp?TOPIC_ID=35394. No posts have been deleted. Open ongoing discussions from the last week have been moved to either ASP.NET 1.0 and 1.1 Beginners http://p2p.wrox.com/asp-net-1-0-1-1-basics-60/ or ASP.NET 1.0 and 1.1 Professional. http://p2p.wrox.com/forum.asp?FORUM_ID=50. See my sticky post inside for more.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.1 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 September 7th, 2004, 04:25 AM
Registered User
 
Join Date: Jun 2004
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default How do I read a label in JavaScript?

Hi I am making an inventory application for pocket PC and I just wanted a quick check to see if I've already inventoried an article today
So I wanted to check the label "latestInv" to todays date and issue an alert if they match.
How do I get the value of the label?
I tried document.form1.latestInv.value, .text, .innerHTML, .youNameIt
but all I get if undefined
please help!
best / Anders

 
Old September 7th, 2004, 01:38 PM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 1,348
Thanks: 0
Thanked 5 Times in 5 Posts
Default

where is the label getting the text from, are you binding it to a column in the DB? If so, why not just check that value instead of the label text

 
Old September 8th, 2004, 09:40 AM
Registered User
 
Join Date: Jun 2004
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Yes the label text is set from the DB but the DB is on the server, I have to read the text on the client, hence jscript.
The label transform to a <span id=latestInv> , there has to be a way to read the content of a span.

 
Old September 8th, 2004, 10:18 AM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

You can read the "contents" of any HTML element by means of the "innerHTML" property. The following should do it. Caution on the capitalization of HTML, I might have it wrong.

document.getElementById("latestInv").innerHTML
 
Old September 10th, 2004, 02:32 AM
Registered User
 
Join Date: Jun 2004
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

The capitalization is fine, the rest however, is not.
I'm developing for Pocket PC wich means Pocket Explorer, wich means JScript instead of the full JavaScript.
.getElementById() is not available nor seems .innerHTML.

I can reach document.form1.latestInv without problems.
Could I assign a value attribute to the span tag?
It seems that I can read .value from most any element.
Anders

PS I re-read my answer and it sounds like I'm chewing your head off
I'm really not I'm really grateful that you take time to help me, I'm just frustrated since this should be a piece of cake, the info is right there on the webpage and the customer is breathing down my neck.:(







Similar Threads
Thread Thread Starter Forum Replies Last Post
pass javascript value to label annieapple Javascript How-To 7 July 5th, 2008 04:04 PM
How to read javaScript variables's values in brows [email protected] C# 0 October 15th, 2007 10:21 AM
Change ASP.NET label color using Javascript shalan99 ASP.NET 2.0 Professional 4 May 22nd, 2007 02:09 AM
can't read value from select tag using javascript kumar_kumar Javascript 2 February 9th, 2005 11:18 PM
Read HTML comments with Javascript benburrows Javascript How-To 3 October 29th, 2004 12:50 PM





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