How to display an image on the javascript

Discussion in 'HTML & Website Design' started by FabioFlash, Oct 6, 2008.

  1. #1
    Hi guys,

    Im having a problem with my code:
    If you go to www.searchtravelonline.co.uk
    there is a searchbox on the left side and it has a button called "advanced search" in which is an image.. the problem is when u click on it .. it opens up the advanced option, but if you close it clicking on "hide" i goes back to normal but the button that was the IMAGE doesnt show anymore and it shows text instead..

    im sending the javascript function...what i need to know i think is how to display an image instead of "<p>advanced search</p>"

    thats my .js:

    function showHideAnswer()
    {
    var numericID = this.id.replace(/[^\d]/g,'');
    var obj = document.getElementById('a' + numericID);
    var obj2 = "";

    if(obj.style.display=='block'){
    obj.style.display='none';
    if (numericID == 1 )document.getElementById("q1").innerHTML = "<p>Advanced Search</p>";
    if (numericID == 2 )document.getElementById("q2").innerHTML = "<p>Edit and recalculate</p>";
    if (numericID == 3 )
    if (numericID == 4 )document.getElementById("q4").innerHTML = "<p>Filter Results</p>";
    {
    obj2 = document.getElementById('d' + numericID);
    obj2.style.display='block';
    document.getElementById("q3").innerHTML = "<p>Read More</p>";
    document.getElementById("e3").innerHTML = ""; }

    }else{
    obj.style.display='block';
    if (numericID == 1 )document.getElementById("q1").innerHTML = "<p>Hide</p>";
    if (numericID == 2 )document.getElementById("q2").innerHTML = "<p>Hide</p>";
    if (numericID == 3 )
    if (numericID == 4 )document.getElementById("q4").innerHTML = "<p>Hide</p>";
    {
    obj2 = document.getElementById('d' + numericID);
    obj2.style.display='none';
    document.getElementById("q3").innerHTML = "";
    document.getElementById("e3").innerHTML = "<p>Hide</p>"; }



    }
    }


    function initShowHideContent()
    {
    var divs = document.getElementsByTagName('DIV');
    for(var no=0;no<divs.length;no++){
    if(divs[no].className=='question'){
    divs[no].onclick = showHideAnswer;
    }

    }
    }

    window.onload = initShowHideContent;
    Edit/Delete Message
     
    FabioFlash, Oct 6, 2008 IP