简体   繁体   中英

Javascript code to hide div

I would like to make a reservations formula but I have very low knowledge for javascript and ajax.

Here is a sample form: http://info.airprishtina.com/content/index.php?id=20&no_cache=1&L=0

When you Einfachflug in the Online buchen on the left, the divs that contain the destinations for returning flights disappear. What is the best way to achieve this effect? because I have seen different techniques but I would like to know what is the easiest and the best way!

They change the style.visibility of the objects. That way the hidden objects will still take up space so the form does not change size.

Alternative is to change the style.display between "none" and "" or "block" Here is my example http://jsfiddle.net/mplungjan/VKxFT/

Here is the actual code they use

function OneOrTwoWayClick() {
    var cb = getObject('fbengine_ui_flightsearchext_ascx_MultiCity');
    if (cb != null) {
        var rb = getObject('fbengine_ui_flightsearchext_ascx_Ticket2Way');
        if (rb.checked) {
            getObject('fbengine_ui_flightsearchext_ascx_MultiCityPanel').style.visibility = 'visible';
        } else {
            getObject('fbengine_ui_flightsearchext_ascx_MultiCityPanel').style.visibility = 'hidden';
            cb.checked = false;
            OnClickedMulticity();
        }
    }

    OneOrTwoWayChk();
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM