willrose84 0 Newbie Poster

I have a java tab script but it only shows the correct data for tab 1 on intital load if you go to another and then back to it it says undefind it is getting a variable from a php page

var tabs = [
                //first tab
                [
                    //tab image when unselected
                    'http://krisp.willrosesolutions.co.uk/Final/themes/blackwhite/img/information-hover.png',
                    //tab image when selected
                    'http://krisp.willrosesolutions.co.uk/Final/themes/blackwhite/img/information-selected.png',
                    //tab data
                    '<p><script type="text/javascript">document.write(productinfo_ro)</script></p>'],
                //second tab
                [
                    'http://krisp.willrosesolutions.co.uk/Final/themes/blackwhite/img/delivery-hover.png',
                    'http://krisp.willrosesolutions.co.uk/Final/themes/blackwhite/img/delivery-selected.png',
                    '<br /><p style="text-align:center">UK Standard Delivery (3-5 working days) £3.95</p><br /><p style="text-align:center">UK Next Day Delivery (if order placed before 12pm): £5.95 Available Monday to Friday, except Bank Holidays</p><br /><p style="text-align:center"><a href="http://www.krisp.co.uk/cms.php?id_cms=1">Please click here for further information on delivery</a></p>'],
                //third tab
                [
                    'http://krisp.willrosesolutions.co.uk/Final/themes/blackwhite/img/returns-hover.png',
                    'http://krisp.willrosesolutions.co.uk/Final/themes/blackwhite/img/returns-selected.png',
                    '<br /><p style="text-align:center">If you are not completely satisfied with your purchase, simply return the item/s to us in their original condition within 14 days of receipt and we will issue a full refund (excluding original delivery charge) on receipt. Please note that sale items are non-refundable, however we can exchange it for a different item if desired.</p><br /><p style="text-align:center"><a href="http://www.krisp.co.uk/cms.php?id_cms=3">Please click here for our complete Returns Policy</a></p>']];
                //you can have more tabs if you want

//if you have empty space between your tabs, adjust this to a lower number
var width = 10;

function preloadImages() {
    for (var y = 0; y < 2; y++) {
        for (var x = 0; x < tabs.length; x++) {
            image = new Image();
            image.src = tabs[x][y];
        }
    }
}

function drawTabs() {
    document.write("<table cellspacing=0 cellpadding=0 border=0><tr>");
    for (var x = 0; x < tabs.length; x++) {
        document.write("<td width="+width+"><a href='javascript:switchTab("+x+")'><img name='tab"+x+"' border=0 src="+tabs[x][0]+"></a></td>");
    }
    document.write("</td><td></td></tr><tr><td id=currentTab colspan="+(tabs.length+1)+">");
    document.write(tabs[0][2]);
    document.write("</td></tr></table>");
    document.images["tab0"].src = tabs[0][1];
}

function switchTab(tab) {
    for (var x = 0; x < tabs.length; x++) {
        if (x != tab)
            document.images["tab"+x].src = tabs[x][0];
    }
    document.images["tab"+tab].src = tabs[tab][1];
    document.getElementById("currentTab").innerHTML = tabs[tab][2];
}

preloadImages();

please can some one help me

many thanks

Will

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.