Thread: replace()
View Single Post
 
Old January 16th, 2004, 10:39 AM
Missy_K Missy_K is offline
Registered User
 
Join Date: Jan 2004
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default replace()

Hi, I am really struggling with a solution for a replacment in a string:

I am tring to replace the IMG tag within a sting containing a whole bunch of html code.

All my functions calls work fine. What I am left with is a different IMG tag depending on weather the image is clickable or not.

function getImageBio(htmlIMG)
{
    var startHREF = "";
    var endHREF = "";
    var tempIMG = "";
    var bioView = "";

    startHREF = htmlIMG.indexOf("<a href=\"bios");
    endHREF = htmlIMG.indexOf("Biography'><\a>");
     tempIMG = htmlIMG.substring(startHREF.endHREF);

    var bioFile = getBio(htmlIMG);
    var picFile = getPic(htmlIMG);

    if(bioFile == "bios/.")
        bioView = viewNoBio(picFile);
    else
         bioView = viewBio(picFile, bioFile);

    htmlIMG.replace(tempIMG, bioView);

    return(bioView);
}

The red font is where I am getting lost. I need a way to replace the tempIMG string with in the htmlIMG string with the bioView string.

Hope this isn't too confusing. I just can't figure it out. Can anyone help???