• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 198
  • Last Modified:

Changing a picture in a table

I have a website and i want it so when you press a button it will change a picture in my table cell how do i do this?
0
mattewjones
Asked:
mattewjones
  • 2
1 Solution
 
mattewjonesAuthor Commented:
And the textin in another cell!
0
 
eyeh8uCommented:
<form>
<input type="button" onclick="imagechange()">
</form>

<img src="image.jpg" id="image1">

<script language="javascript">
<!--
function imagechange()
{
  document.all['image1'].src = 'newimage.jpg';
}
//-->
</script>
0
 
eyeh8uCommented:
Ah didn't see your new comment:

<form>
<input type="button" onclick="imagechange()">
</form>


<script language="javascript">
<!--
function imagechange()
{
  document.all['image1'].src = 'newimage.jpg';
  document.all['td1'].innerHTML = 'bar';
}
//-->
</script>

<table>
<tr><td><img src="image.jpg" id="image1"></td><td id="td1">foo</td></tr>
</table>
0

Featured Post

[Webinar On Demand] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now