Meaningless Drivel is fun!*
The moose likes HTML, CSS and JavaScript and the fly likes Obtaining data from form elements Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Obtaining data from form elements" Watch "Obtaining data from form elements" New topic
Author

Obtaining data from form elements

K Robert
Ranch Hand

Joined: May 16, 2003
Posts: 116
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

Joined: Nov 08, 2001
Posts: 15376
    
    6
document.getElementById("elementId").innerHTML = "something";

Eric
K Robert
Ranch Hand

Joined: May 16, 2003
Posts: 116
Eric,

Thanks!
K Robert
Ranch Hand

Joined: May 16, 2003
Posts: 116
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

Joined: Nov 08, 2001
Posts: 15376
    
    6
No, it does not have a value attribute.

Eric
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14688
    
  16

Eric, I thought that innerHTML was kind of deprecated and that we should avoid using it. Could you comment on this ?


[My Blog]
All roads lead to JavaRanch
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
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

Joined: May 16, 2003
Posts: 116
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

Joined: Nov 08, 2001
Posts: 15376
    
    6
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

Joined: May 16, 2003
Posts: 116
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

Joined: May 16, 2003
Posts: 116
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?
 
GeeCON Prague 2014
 
subject: Obtaining data from form elements