Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Obtaining data from form elements

 
K Robert
Ranch Hand
Posts: 116
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Howdy! Currently, I have the following script:



That script uses this input field:
,
to insert the proper value.

The requirements have changed to insert the value into:


Is there a way to identify a unique table-data tag to replace the "tfName" in the script?

Thanks in advance.
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
document.getElementById("elementId").innerHTML = "something";

Eric
 
K Robert
Ranch Hand
Posts: 116
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Eric,

Thanks!
 
K Robert
Ranch Hand
Posts: 116
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is there a way to populate the td-tag utilizing something like: "form.tdID.value ="? Or something along those lines? Just curious as if the innerHTML is the only was to populate plain-text on the document.
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No, it does not have a value attribute.

Eric
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Eric, I thought that innerHTML was kind of deprecated and that we should avoid using it. Could you comment on this ?
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Um innerHTML is not. It was not part of the standards, but every major browser has it. Most people that use Ajax rely on it since DOM methods are slow.

Eric
 
K Robert
Ranch Hand
Posts: 116
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If there is no value attribute, how can I grab the value of the td tag which is set using innerHTML? I need to grab all td tags that have an "id" attribute and the associated value to create string of name/value pairs. Here is what I have so far:



I can grab the length, but I can't seem to grab the id attribute or the value of the tag which is set via innerHTML.
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
a call does not have a value so how can you grab it? You need to grab the innerHTML of the cell.



Eric
 
K Robert
Ranch Hand
Posts: 116
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the help. When I implement this, it is pulling all of the td tags if they have an id attribute or not. Is this to be expected? I tried "if (tds.id != ""){}", and variations thereof, to only print the td tags with id attributes, but that doesn't work.
 
K Robert
Ranch Hand
Posts: 116
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
NVM. I think I got it... I had to dump the results into "lItem = tds.item(i);" before I could access them. Is that right?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic