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

Change filed without refreshing page 1

Status
Not open for further replies.

JamesManke

Programmer
Jul 1, 2004
54
CA
What I want to do is have it so when you select a color in the form, it automatically changes the field "color_change" without refreshing the page.
Here is the code if you would like to alter it and post back.
Thanks


<table>
<tr>
<td name="color_change" id="color_change">Show Color Name Here</td>
</tr>
<tr>
<td>
<select name="colors" onmousedown="???">
<option value="Red">Red</option>
<option value="Green">Green</option>
<option value="Blue">Blue</option>
</select>
</td>
</tr>
</table>

 
not sure if you wanted to change the actual color or the text of the table item, so this will do both:
Code:
<script language=javascript>
function changeColor(newColor) {
   document.getElementById("color_change").innerHTML = newColor;
   document.getElementById("color_change").style.backgroundColor = newColor;
   
}
</script>
<table>
<tr>
<td name="color_change" id="color_change">Show Color Name Here</td>
</tr>
<tr>
<td>
<select name="colors" onchange='changeColor(this.value)'>
<option value="Red">Red</option>
<option value="Green">Green</option>
<option value="Blue">Blue</option>
</select>
</td>
</tr>
</table>

-kaht

Do the chickens have large talons?
[banghead]
 
No problem [smile]

-kaht

Do the chickens have large talons?
[banghead]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top