Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

re: Node values. Trouble getting/changing a text value of a node.

Status
Not open for further replies.

jjbrad

Programmer
Feb 8, 2005
10
US
I have a total field that I just want to appear as normal text. It is in a table that can have unlimited rows.

My environment is ASP using Javascript for client side edits.

I have the RowNumber of the <TR> so can access the nodes.

To reduce the problem,
I've tried using "alert()" and set up an anchor (<a href=...>) and am trying to display the value, as follows:
(note: this is paraphrased, this isn't the actual code I'm running, excuse any slight typo, but this gives the idea)



function fnDisplayIt(objIn, rowNumIn){

//Recreate as local objects for better referencing.
var obj=objIn;
var rowNum=rowNumIn;

// this will get an error saying "obj.parentNode not object"
alert(obj.parentNode.nodeName);

// this will say "undefined"
alert(obj.nodeName);

// I can't figure out any container to assign "txtMyField"
// to. Tried "<tt id=txtMyField name=txtMyfield>
alert(document.form1.txtMyField(rowNum).value);
}

.
.
.
var rowNum=0;
<% do until rst.eof%>

<td><a href="javascript:fnDisplayIt(this,rowNum)">
<%="MyTotalField"%></a>
rowNum=rowNum+1;
.
.
.


I'm pretty confused about when nodes will have values and when they will have parents.

It appears that only INPUT controls can have values that are referenced by the "document.form..." model. However, I thought that the DOM model allowed full navigation of the table tree, giving access to all elements including text values.

In case you're wondering, this is an Inventory Maintenance screen where they see about 50 inventory items at a time. They go down the screen making multiple changes before pressing submit. I do all sorts of recalculating, automatic populating, color coding for lines changed, etc. BEFORE they press submit. So this program does a lot of client JavaScript value changes.

Of course, the easy answer is to make everything an input field, and simply disable the ones I don't want them to change. I'm just wondering if that's the only option since I'm no good at using STYLE and I can't figure out how to eliminate the Boxes and make things look appropriate for total fields that don't allow user edits (ie: no box).
 
Ummm, sorry.

Haven't used nodes much, but re-reading my post just rang a bell called "textNode", with its nice property called "data".

I think that will solve my text manipulation problem, and I recall testing this and it seemed to work as advertised.

I'm still confused about node navigation since it sometimes doesn't seem to work and neat and easy as all the many examples I see online.

One question remains however. Why is obj.parentNode not a valid object? Since this is in a table, I would expect the parentNode to be of the <TD> variety.

Does someone know of a good "node navigation" writeup that's for Dummies like me? One that anticipates the times when "geee, that oughta work" but doesn't.

I'm reading one at


which makes it look like childsplay (no pun intended), but its still not answering my question about why my parentNode still doesn't exist.

Thanks!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top