473,326 Members | 2,102 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

Text from an Element, w/ a twist

Hi All-

Problem: text from an elem is coming back as the text from the original
HTML, not the current, dynamic value. The DOM inspector and the screen
show the new value. the value from getElementById show the old value.
What gives ?

I have learned tonight that reading text from an element node is not
straightforward. I read some of the posts and have used
elem.firstchild.data. I wrote the HTML I am reading from. I use Firefox
(but I know most others don't. I have to be compatible, but that's for
later)

I start out with a hidden field set to an INIT value. I set a value as
a result of some tricky actions, _which work_ (a SQL query). I want to
read the result immediately after the SQL subroutine call, at the next
line. I use getElementById_s() (below) to get the element but that
should not matter. Here is the problem area

// .....
// check return result in a hidden field
var elem = getElementById_s('divZipCheckRes');
if ( null == elem ) {
window.alert( "introZipCheck() - Problem finding result?");
return false;
}
var tNode = elem.firstChild;

if ( "1" != tNode.data) {
window.alert( tNode.data + " Is that a valid California Zip
Code?");
return false;
}

return true;
----

the data returned in the alert() is the INIT value! But the screen
shows "1" (as does the DOM inspector). ideas appreciated...

----
// getElementById Special to handle quirky browsers
// most will use getElementById()
function getElementById_s(id){
var obj = null;
if(document.getElementById){
/* Prefer the widely supported W3C DOM method, if
available:-
*/
obj = document.getElementById(id);
}else if(document.all){
/* Branch to use document.all on document.all only
browsers. Requires that IDs are unique to the page
and do not coincide with NAME attributes on other
elements:-
*/
obj = document.all[id];
}
/* If no appropriate element retrieval mechanism exists on
this browser this function always returns null:-
*/
return obj;
}
----
Jan 20 '06 #1
3 1433


one man army wrote:

I start out with a hidden field set to an INIT value.
What HTML element exactly, a hidden input e.g.
<input type="hidden" name="inputName" value="INIT">
I set a value as
a result of some tricky actions, _which work_ (a SQL query).


What kind of "value" do you set, how do you do that, post the code, at
least outline it. SQL queries usually happen on the server while most
issues we are dealing here with are client-side JavaScript, and what you
have below looks like client-side JavaScript.
If you have the browser connect to the server so that it does an SQL
query then we need to know how you do that.
--

Martin Honnen
http://JavaScript.FAQTs.com/
Jan 20 '06 #2
In article <43***********************@newsread2.arcor-online.net>,
Martin Honnen <ma*******@yahoo.de> wrote:
one man army wrote:

I start out with a hidden field set to an INIT value.


What HTML element exactly, a hidden input e.g.
<input type="hidden" name="inputName" value="INIT">


oh.. not knowing, I used a <div> then tried to get the text out.
Setting the value was easy. I set it to "1" on success, or the SQL error
or my own error msg on failure. Perhaps I should use an INPUT type TEXT,
and that would be easier/more reliable to get text back out of.
I set a value as
a result of some tricky actions, _which work_ (a SQL query).


What kind of "value" do you set, how do you do that, post the code, at
least outline it. SQL queries usually happen on the server while most
issues we are dealing here with are client-side JavaScript, and what you
have below looks like client-side JavaScript.
If you have the browser connect to the server so that it does an SQL
query then we need to know how you do that.


yeah, that matters, but it is a little involved.

What I noticed after the post was that I often get the _previous_
result. So the first time through, I get the INIT text. A second time
through, I get the FIRST result back. Even though the screen has
apparently been updated.

I am wondering if I need to chain events in order to handle and kind of
latency. Can I initiate a click or somesuch, the return, and on the
click handler read the value and process? This is something I had used
in tricky situations in a previous programming environment.

further thoughs on this welcome, 'cause right now the page does not
work. thanks
Jan 20 '06 #3
um, perhaps poor wording in the response. POST means something in this
group, I meant 'after writing the newsgroup response'.

what I am trying to acheive is an update in place on a web page using
Javascript events and the DOM. I am all the way through coding the
action, and now I am simply trying to interpret the response, which has
been set inside a DOM element. I am getting some kind of delay/latency
problem reading the reponse.

So I am asking if chaining events is ever done here. When the event
that initiated the action completes, it initiates another event as its
last action. I then handle that event and the latency is settled down.
Am I getting warmer?

thanks
Jan 20 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Martin | last post by:
Hallo, can you help me writing a generic xslt transformation (useable with xsql from oracle)? The problem is how to get the escaping characters .... === INPUT-File in.xml <?xml version =...
1
by: Gordon - Adelphia | last post by:
I have a question regarding xhtml. Why, why, why does the ELEMENT <body> allow “unblocked” text. HTML does not (though, most browsers will render). Xhtml (transitional) however allows text nodes...
4
by: michael | last post by:
I have an html text string within a div, eg.: <div id="example">Text text text</div> I know its easy to change styles by using getElementById - for example: ...
9
by: Haobin | last post by:
Hi everyone, I have an ArrayList whose members are classes. These classes are derived from a same base class. The base class has a floating point array and a string. How do I access each element in...
1
hpbutterbeer
by: hpbutterbeer | last post by:
We have a Machine Project and my brain is currently in a clouded state. Sorry, I'm just a beginner in C Programming... Text twist is a windows game whose main objective is to form words out of the...
0
by: Steven Bethard | last post by:
I'm trying to align an XML file with the original text file from which it was created. Unfortunately, the XML version of the file has added and removed some of the whitespace. For example:: ......
9
by: Steven Bethard | last post by:
I have some text and a list of Element objects and their offsets, e.g.:: ... (etree.Element('a'), 0, 21), ... (etree.Element('b'), 11, 18), ... (etree.Element('c'), 18, 18), ... ] ...
1
by: littlealex | last post by:
IE6 not displaying text correctly - IE 7 & Firefox 3 are fine! Need some help with this as fairly new to CSS! In IE6 the text for the following page doesn't display properly - rather than being...
4
by: Chuckhriczko | last post by:
I need to possibly twist an image on the z axis in Javascript. Here is the deal. We have sliding effects and so forth for our company's website but there is too much sliding. We want something more...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.