Add your website to the Xemion web designer directory and gain highly-targeted traffic and new leads.

Change multiple span text to the same value

Post Reply
 
Thread Tools
 
#1 October 31, 2007 by krug - Junior Member, 3 posts PHP: , RoR: , CSS/XHTML:  , Design: , Javascript: , ASP/.NET: , SEO: , SQL: Reputation Level
ere's what I need to do:

I have several variables that I want to assign to various spans within a page (i.e. customer_name, customer_address, etc.). Now, I am going to have more than a 1 span that I dynamically need to assign the customer_name to. But I want it to be able to do so without me having to name them all "customer_name1, customer_name2, customer_name3" and then having to go through and manually change each one, one-by-one within the function.

What I'd like to do is ultimately have the function loop through every span with the name or id of "customer_name" and change the innerHTML within it to whatever the value of the costomer's name variable is ("John Doe" for example).

I've tried a few ways, most of the time it only changes 1 instead of all of them.

Can anyone help?
Post Reply

Thread Tools