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 biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Writing text to form in javascript 1

Status
Not open for further replies.

dokken

Programmer
Mar 7, 2001
61
US
I have a table of data and I want to be able to write to a specific column in every row. I know this would be easy if the column was a input of type text. Is there a way I can used DHTML and identify the column and write a value via javascript?

Thanks
Paul
 
You should be able to use <span> tags to get that done...

<td>
<span id=mySpan></span>
</td>

Then, you could write to that table cell by saying something like:

document.mySpan.value = &quot;Whatever you want here&quot;;

hope it helps! :)
Paul Prewett
 
I tried the sample code you wrote but I get an error message when I try to do the following: document.form1.myspan.value = &quot;test&quot;;

It says the myspan is not an object.
 
myspan is not contained within the form namespace. for IE5+/mozilla use:

document.getElementById(&quot;myspan&quot;).innerHTML = &quot;Whatever you want <b>here</b>&quot;;

for IE4 compatibility, try:

myspan.innerHTML = &quot;benluc&quot;

and forget NS4, it's not gonna happen. ;-) jared@eae.net -
 
... or as part of the document.all collection: &quot;document.all[&quot;myspan&quot;].innerHTML

Also... there is no need to &quot;forget&quot; Netscape4.x or 6. They both can write data to <DIV> layers just fine. Unfortunately they each use different syntax; has a library for cross-browser handling of layers that works well for both NS4.x and IE4+.

For Netscape 6, I don't recall right now where I saw it, but there is a property that closely resembles innerHTML.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top