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

Changing HTML Text 1

Status
Not open for further replies.

ToddWW

Programmer
Mar 25, 2001
1,073
US
Hello Guys & Gals,

Here's my basic HTML code right now:

<html>
<script Language=&quot;JavaScript&quot;>
<!--
function changeHeading() {
if (document.forms[0].maptype.value == &quot;1&quot;) {
// Column Headings Should Be
// Start Position
// End Position

}
if (document.forms[0].maptype.value == &quot;2&quot;) {
// Column Headings Should Be
// Field Number
// Delimiter

}
}
//-->
</script>
<body>
<form>
<select name=&quot;maptype&quot; onChange=&quot;changeHeading();&quot;>
<option selected value=&quot;1&quot;>Fixed Width</option>
<option value=&quot;2&quot;>Delimited</option>
</select><br><br>
<table width=&quot;100&quot;>
<tr>
<td width=&quot;50&quot;>Start Position</td>
<td width=&quot;50&quot;>End Position</td>
</tr>
<tr>
<td width=&quot;50&quot;><input type=&quot;text&quot; name=&quot;T1&quot;></td>
<td width=&quot;50&quot;><input type=&quot;text&quot; name=&quot;B1&quot;></td>
</tr>
<tr>
<td width=&quot;50&quot;><input type=&quot;text&quot; name=&quot;T2&quot;></td>
<td width=&quot;50&quot;><input type=&quot;text&quot; name=&quot;B2&quot;></td>
</tr>
</table>
</form>
</body>
</html>


I want that JavaScript function, which fires when the select list changes, to change the column headings in the table. Don't read into the names of the column headings thinking that I'm looking for some kind of variable. I just want to change the HTML text. I'm a newbie to Dynamic HTML. Is there an easy way to do this ??

Any help would be greatly appreciated.

ToddWW
 
I think you can name the <td>, <td name=&quot;blah&quot;.....> then use
document.getElementById('name').innerHTML = &quot;text to put in <td>&quot; for ie...i'm not sure about a ns solution...ask in the javascript forum..vituz or tsdragon should be able to help you out -Greg :-Q

flaga.gif
 
Well, this is what I tried, and I got an object error document.getElementById(...) is not an object from JavaScript.


<html>
<script Language=&quot;JavaScript&quot;>
<!--
function changeHeading() {
if (document.forms[0].maptype.value == &quot;1&quot;) {
document.getElementById(&quot;col1&quot;).innerHTML = &quot;Start Position&quot;
document.getElementById(&quot;col2&quot;).innerHTML = &quot;End Position&quot;
}
if (document.forms[0].maptype.value == &quot;2&quot;) {
document.getElementById(&quot;col1&quot;).innerHTML = &quot;Field Number&quot;
document.getElementById(&quot;col2&quot;).innerHTML = &quot;&quot;
}
}
//-->
</script>
<body>
<form>
<select name=&quot;maptype&quot; onChange=&quot;changeHeading();&quot;>
<option selected value=&quot;1&quot;>Fixed Width</option>
<option value=&quot;2&quot;>Delimited</option>
</select><br><br>
<table width=&quot;100&quot;>
<tr>
<td name=&quot;col1&quot; width=&quot;50&quot;>Start Position</td>
<td name=&quot;col2&quot; width=&quot;50&quot;>End Position</td>
</tr>
<tr>
<td width=&quot;50&quot;><input type=&quot;text&quot; name=&quot;T1&quot;></td>
<td width=&quot;50&quot;><input type=&quot;text&quot; name=&quot;B1&quot;></td>
</tr>
<tr>
<td width=&quot;50&quot;><input type=&quot;text&quot; name=&quot;T2&quot;></td>
<td width=&quot;50&quot;><input type=&quot;text&quot; name=&quot;B2&quot;></td>
</tr>
</table>
</form>
</body>
</html>


I'll try JavaScript forum. Thanks for your help.

ToddWW
 
You gotta id the cells, not name them.

[bb]
 
also a mistake on my part you need to give id's not names..sorry it should work now for ie 5 and up -Greg :-Q

flaga.gif
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top