I have the following function that will dynamically change and email address based on the id of a table data tag.
function changeEmail (id,email)
{
var elements=document.all;
//loop through all the elements
for(i=0; i<elements.length; i++)
{
if (elements.id == id)
elements.innerHTML="<a href=\"mailto:"+email+"\">"+email+"</a>";
}
}
The problem with this is that for some reason it can take several seconds to loop through all the elements on a page. I then realized that you can substitute the element address in elements with the id itself. So the following will give you the current email address tag.
elements[id].innerHTML
but oddly enough what worked above does not work here:
elements[id].innerHTML = "<a href=\"mailto:"+email+"\">"+email+"</a>"
This whole issue could be resolved easily if you could use a href in an <input> then just do something like document.forms[0].field.value = new address. But since you can't do this you are forced to use innerHTML.
Any ideas why this would not work or another way to quickly change data on a page that is not a form input.
function changeEmail (id,email)
{
var elements=document.all;
//loop through all the elements
for(i=0; i<elements.length; i++)
{
if (elements.id == id)
elements.innerHTML="<a href=\"mailto:"+email+"\">"+email+"</a>";
}
}
The problem with this is that for some reason it can take several seconds to loop through all the elements on a page. I then realized that you can substitute the element address in elements with the id itself. So the following will give you the current email address tag.
elements[id].innerHTML
but oddly enough what worked above does not work here:
elements[id].innerHTML = "<a href=\"mailto:"+email+"\">"+email+"</a>"
This whole issue could be resolved easily if you could use a href in an <input> then just do something like document.forms[0].field.value = new address. But since you can't do this you are forced to use innerHTML.
Any ideas why this would not work or another way to quickly change data on a page that is not a form input.