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!

String Manipulation Help needed

Status
Not open for further replies.

certizoid

Programmer
May 11, 2001
9
US
how can I change "ford" into simply ford ? in one part of my code: ford.src will change an image.

<script language=&quot;JavaScript&quot;> <!-- preload blank image -->
function change()
{
ford.src= &quot;images/&quot; + pres_name + &quot;.jpg&quot;
}
</script>

but I need to use a string variable (to account for all the presidents)

using &quot;ford&quot;.src does not work. ford is the image name (see below)

here is my call from an href:

<a href='javascript:change(get_pres())' >
<img class=m1 src=&quot;images/blank.jpg&quot; name=&quot;ford&quot;>
<a>

NOTE: get_pres() works fine

Thanks
 
I'm not sure what you mean but will this help...


Code:
function change(pres_name, imgName)
{
 eval(imgName + &quot;.src = 'images/&quot; + pres_name + &quot;.jpg&quot;);
}

called by...

<a href='javascript:change(get_pres(), &quot;ford&quot;);&quot;> [COLOR=blue]Klae[/color]

You're only as good as your last answer!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top