commas in the string.

    Date: 05/31/06 (WebDesign)    Keywords: html, database, java

    So I have this simple function that swaps an image and its caption on an HTML page:


    function changeBigImg(source, content) {
    if (source != null) {
    document.getElementById("showedImage").src = source;
    document.getElementById("imageCaption").innerHTML = content;
    }
    }


    The problem being is that 'content' is being fed from a database, and I have no pull on how they enter the data, and some of the strings being fed into 'content' contain commas, which break the function.

    If the title of the image has commas or single quotes, then the JS image switching fuction does not work.

    edited to add examples-

    This one works:

    javascript:changeBigImgSideBar('/photo_servlet?contentId=34153&ver
    sion=1&locale=EN-US&subtype=MIMG','Napoleon Dynamite wishes he had skills like this','height')

    This one does not:

    javascript:changeBigImgSideBar('/photo_servlet?contentId=33918&ver
    sion=1&locale=EN-US&subtype=MIMG','Cindy, Kim, and Q doing their best Sinead O'Connor impersonations','width')

    Slight variance from js protocol in my examples aren't the problem -- it consistently happens with commas and/or single-quotes.

    So I was pondering if anyone had a suggestion for a way to replace the commas in the string with commas that will only be read as text, not seperators.

    Thank you!

    Source: http://community.livejournal.com/webdesign/1118592.html

« How do you find freelance... || hosting question »


antivirus | apache | asp | blogging | browser | bugtracking | cms | crm | css | database | ebay | ecommerce | google | hosting | html | java | jsp | linux | microsoft | mysql | offshore | offshoring | oscommerce | php | postgresql | programming | rss | security | seo | shopping | software | spam | spyware | sql | technology | templates | tracker | virus | web | xml | yahoo | home