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

onClick change text (span) 1

Status
Not open for further replies.

kstargold

Programmer
Jun 7, 2004
27
0
0
US
I have three parts to this problem.

Code:
<script language="JavaScript">
<!--
function changeLeftSide (image_ref, title, desc) {
	var objImg = new Image;
	objImg.src = "../imgs/" + image_ref;

	document.images["image_ref"].src = objImg.src
	document.getElementById("image_title").interHTML = title;
	document.getElementById("desc").interHTML = "not it";
}
//-->
    </script>
The Function


Code:
<a href="#" onClick="javascript:changeLeftSide('thumb_kungfu.jpg',' KUNG FU','design of website and back end development');" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('document.Image7','document.Image7','/imgs/b_1_on.gif','7')">
<img name="Image7" src="/imgs/b_1_off.gif" width="21" height="21" border="0" alt=""></a>
The Call


Code:
<div style="position:absolute; left:10px; top:330px;">
<table width="220" border="0" cellspacing="0" cellpadding="0" bgcolor="#E5E7EB">
  <tr>
    <td>
      <b><span id="image_title" style="padding-left:8px;">&nbsp;</span></b>
    </td>
  </tr>
</table>
<img src="/imgs/thumb_blank.jpg" width="208" height="198" border="0" name="image_ref" alt="">
<table width="220" border="0" cellspacing="0" cellpadding="0" bgcolor="#E5E7EB">
  <tr>
    <td>
      <span id="image_desc" style="padding-left:8px; font-weight:bold;">Please choose item from right</span><br>
    </td>
  </tr>
</table>
</div>
And the span


What is going wrong with this???

The image swap works, but I can't get the text swap to work for the life of me!

Any suggestions??

Thanks,
Kstar
 
The method you are trying to use is in[red]n[/red]erHTML. Make these changes and it should work fine:
Code:
    document.getElementById("image_title").in[red]n[/red]erHTML = title;
    document.getElementById("desc").in[red]n[/red]erHTML = "not it";

-kaht

banghead.gif
 
Wow, I could have searched with dogs for days and never found that. Thanks for the tip, have a star.

Kstar
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top