Page is a not externally linkable
- Code, Content, and Presentation
-- JavaScript and AJAX
---- Javascript to update a cell and a text box


starway - 5:50 pm on Aug 26, 2002 (gmt 0)


This is rather simple using standard DOM:

function changeBgr(element, color) {
document.getElementById(element).style.backgroundColor = color;
document.form1.field1.value = color;
}

The cell (or div) you're changing should have the ID set:
<td id="first"> or <div id="second">,

and the text field is named "field1" and placed inside form1:

<form name="form1">
<input type="text" name="field1">
</form>

The function should be called like this:

<a href="#" onclick="changeBgr('first', '#339966')" title="click to change backgr color"><img src="transp.gif" width=... height=... border="0"></a>


Thread source:: http://www.webmasterworld.com/javascript/181.htm
Brought to you by WebmasterWorld: http://www.webmasterworld.com