jquery.data not working in ie7
<p>i am developing a web site an it is working fine in firefox ie8 and ie9.</p>

<p>i stored some data using jquery.data() function , when i try to retrieve it later it works in firefox , ie8, ie9 , but it says undefined in ie6 and ie7 . </p>

<p>i figured that .data() is not working in ie6 and ie7 .</p>

<p>i tried to alert the stored value right after stroing , but it is not working , </p>

<p>like this </p>

<pre><code>$('#'+ k +'-'+ offer.key +' td input[type=button]').data('roomtypekey',k);
alert($('#'+ k +'-'+ offer.key +' td input[type=button]').data('roomtypekey'));
</code></pre>

<p>it is working properly in firefox , ie8, ie9 .</p>

<p>this is my code </p>

<pre><code>(function( $ ){

    var dict = null;
    var alldata = null;
    var roomtypes = [];
    var oneroomtypeadded = false;
    var calculated = null;

    var keyfuncmap = {
        'data' : function(data){
                                    alldata = data;

                                    //alert(avail.dict.FB.vn);

                                    // iterate through each offer
                                    $.each(data,function(key,value){                                    

                                        if(dict &amp;&amp; dict[key]){

                                            var offer = {};
                                            offer.key = key;
                                            offer.keyvn = dict[key].vn;

                                            offer.roomrates = {};
                                            // iterate through each room type in current offer
                                            $.each(value,function(k,v){

                                                // check if the room type was found in another offer 
                                                if(!roomtypes[k] || roomtypes[k] != true){
                                                    var roomtype = {};
                                                    roomtype.key = k; 
                                                    roomtype.img = v.img;
                                                    roomtype.desc = v.desc;
                                                    roomtype.vn = dict[k].vn;
                                                    roomtypedivcreator(roomtype);
                                                    roomtypes[k] = true;                                                

                                                }
                                                if(v.meals){ 
                                                    offer.roomrates[k] = {}; 
                                                    offer.roomrates[k].vn = dict[k].vn;
                                                    offer.roomrates[k].meals = v.meals;                                                                                         
                                                    offer.roomrates[k].curr = v.curr;
                                                }
                                            });
                                            offertablecreator(offer,dict);
                                        }
                                    });

                                    $('#left table input[type=button]').click(roomtypeadded);
                                    $('#meal_plan_box table.roomtypeadded td input[type=button]').live('click',roomtyperemoved);

                                    $('#meal_plan_box table.roomtypeadded td select.mealplanselect').live('change', mealplanselectchanged);
                                    $('#meal_plan_box table.roomtypeadded td select.roomselect').live('change',roomselectchanged);
                                    $('#meal_plan_box table.roomtypeadded td select.occuselect').live('change',occuselectchanged);
                                    $('#meal_plan_box table.roomtypeadded td.adlt select.adultselect').live('change',adultselectchanged);
                                    $('#meal_plan_box table.roomtypeadded td.chld select.childselect').live('change',childselectchanged);
                                    $('#meal_plan_box table.roomtypeadded td.inft select.inftselect').live('change',inftselectchanged);
                                    $('#calculate_box input[type=button]').live('click',calculaterate);
                                },
        'dict' : function(data){ dict = data; }
    };


    $.fn.emeDataProcessor = function( data ){
        $.each(data,function(key,value){
            if(keyfuncmap[key] &amp;&amp; $.isFunction( keyfuncmap[key] )){
                keyfuncmap[key].call(this,value);
            }
        });
        return this;
    };


    function offertablecreator(offer,dict){
        $('#left div').append('&lt;table id="'+ offer.key +'_outer" class="offer_table"&gt;&lt;/table&gt;');
        $('#'+offer.key + '_outer').append('&lt;thead&gt;&lt;th&gt;' + offer.keyvn + '&lt;span style="font-size:9px;"&gt;&amp;nbsp;( showing single rates )&lt;/span&gt;&lt;/th&gt;&lt;/thead&gt;');
        $('#'+offer.key + '_outer').append('&lt;tr&gt;&lt;td class="td_bg"&gt;&lt;table id="'+ offer.key +'" class="percent100"&gt;&lt;/table&gt;&lt;/td&gt;&lt;/tr&gt;');      

        $.each(offer.roomrates,function(k,v){

            var mealtyperows = '';

            $.each(offer.roomrates[k].meals, function(index, value) { 
                mealtyperows += '&lt;tr  id="'+ k +'-'+ offer.key +'"&gt;&lt;td class="percent45 padleft20"&gt;'+dict[index].vn+'&lt;/td&gt;&lt;td class="percent15 textalignright"&gt;From&amp;nbsp;:&amp;nbsp;&lt;/td&gt;&lt;td&gt;'+v.curr +' ' +value+'&lt;/td&gt;&lt;td class="percent15"&gt;&lt;input type="button" class="button" id='+ index +'  value="Add" /&gt;&lt;/td&gt;&lt;/tr&gt;';
            });                             

            $('#'+ offer.key).append('&lt;tr id="'+ k +'-'+ offer.key +'"&gt;&lt;td class="percent30"&gt;&lt;strong&gt;'+ v.vn +'&lt;/strong&gt;&lt;/td&gt;&lt;/tr&gt;'+mealtyperows);                                                      
            $('#'+ k +'-'+ offer.key +' td input[type=button]').data('roomtypekey',k);
            $('#'+ k +'-'+ offer.key +' td input[type=button]').data('offerkey',offer.key);

        });
    }


    function roomtypedivcreator(roomtype){
        $('#room_types_box').append('&lt;div id="'+ roomtype.key +'_div" class="roomtypediv"&gt;&lt;img src="'+ roomtype.img +'"/&gt;&lt;div&gt;&lt;strong&gt;'+ roomtype.vn +'&lt;/strong&gt;&lt;p&gt;'+ roomtype.desc +'&lt;/p&gt;&lt;/div&gt;&lt;div class="clearboth"&gt;&lt;/div&gt;');
    }


    function roomtypeadded(){

        var roomtypekey = $(this).data('roomtypekey');
        var offerkey = $(this).data('offerkey');
        var mealtype = $(this).attr('id');

        if(!oneroomtypeadded){ 
            oneroomtypeadded = true;
            $('#room_types_box &gt; div.roomtypediv').hide();
            $('#calculate_box').append('&lt;input type="button" class="button" value="Calculate Rate" /&gt;');
            var tmp = '&lt;span&gt;Airport Transfers&lt;/span&gt;';
            tmp += '&lt;input type="radio" style="width: 15px;" value="yes" id="air-trans-yes" name="air-trans"&gt;&lt;span class="inline"&gt;Yes&lt;/span&gt;';
            tmp += '&lt;input type="radio" style="width: 15px;" value="no" id="air-trans-no" name="air-trans"&gt;&lt;span class="inline"&gt;No&lt;/span&gt;';
            $('#meal_plan_box').after('&lt;div id="transport_box"&gt;'+ tmp +'&lt;/div&gt;');
            $('#air-trans-no').attr('checked','checked');
            $('#air-trans-yes, #air-trans-no').change(function(){
                if ($('#air-trans-no').attr('checked') == true) {

                }
                else {

                }
                calculationInvalidated();
            });
        }
//alert("offer key -&gt; "+offerkey);      
//alert("room type key -&gt; "+roomtypekey);
//alert("meal type -&gt; "+mealtype);

        $('#'+ roomtypekey +'_div').appendTo('#room_types_box').show();

        if(dict &amp;&amp; dict[offerkey] &amp;&amp; dict[roomtypekey] &amp;&amp; alldata &amp;&amp; alldata[offerkey] &amp;&amp; alldata[offerkey][roomtypekey] &amp;&amp; alldata[offerkey][roomtypekey].meals &amp;&amp; alldata[offerkey][roomtypekey].rooms ){         

            var num_of_rooms = alldata[offerkey][roomtypekey].cnt ;     
            var sum = 0 ;       
            var numbr_of_options = num_of_rooms - $('#'+roomtypekey+' .firstrow').length;       

            $('#'+roomtypekey+' .firstrow').each(function() {
                sum += parseInt($(this).find('.roomselect option:selected').text());
            });

            $('#'+roomtypekey+' .firstrow').each(function() {

                var increment = (num_of_rooms) - sum ;

                if(increment == 0) {
                    increment = 1 ;
                }

                var result ='';
                var i = 1 ;
                for(i ; i &lt; (parseInt($(this).find('.roomselect option:selected').text()) + increment) ; i++){

                    if ( i == parseInt($(this).find('.roomselect option:selected').text()) ) {
                        result += '&lt;option value="' + i + '" selected="selected"&gt;' + i + '&lt;/option&gt;';
                    }else{
                        result += '&lt;option value="' + i + '"&gt;' + i + '&lt;/option&gt;';
                    }           
                }           
                $(this).find('.roomselect').html(result);

            });     
            var availabale_rooms = num_of_rooms- sum ;  

            if(availabale_rooms == 0) {
                alert("no rooms available");
            }
            else {
                $(this).attr('disabled','disabled');
                $(this).addClass('disabledbutton');

                var hasid = 0 ;
                $('.outer').each(function() {
                    if($(this).attr('id') == roomtypekey) {
                        hasid = 1 ;
                    }
                });

                if(!hasid) {
                    $('#meal_plan_box').append('&lt;table id='+roomtypekey+' class="outer"&gt;&lt;thead&gt;&lt;tr&gt;&lt;th&gt;'+ dict[roomtypekey].vn +' - '+ dict[offerkey].vn + ' ( ' + alldata[offerkey][roomtypekey].cnt +' Rooms Available )&lt;/th&gt;&lt;/tr&gt;&lt;/thead&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class="td_bg"&gt;&lt;table id="'+ roomtypekey +'-'+ offerkey +'_added" class="roomtypeadded"&gt;&lt;/table&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;');
                }

                $('#'+ roomtypekey +'-'+ offerkey +'_added').append('&lt;tr class="header"&gt;&lt;td colspan="4"&gt;&lt;strong&gt;'+dict[mealtype].vn+'&lt;/strong&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr class="header"&gt;&lt;td&gt;Rooms&lt;/td&gt;&lt;td&gt;Occupancy&lt;/td&gt;&lt;td class="adlt"&gt;Adults&lt;/td&gt;&lt;td class="chld"&gt;Children&lt;/td&gt;&lt;td class="inft"&gt;Infants&lt;/td&gt;&lt;td&gt;&amp;nbsp;&lt;/td&gt;&lt;/tr&gt;');

                $('#'+ roomtypekey +'-'+ offerkey +'_added').data('roomtypekey', roomtypekey);
                $('#'+ roomtypekey +'-'+ offerkey +'_added').data('offerkey', offerkey);        
                $('#'+ roomtypekey +'-'+ offerkey +'_added').data('cnt',num_of_rooms);
                $('#'+ roomtypekey +'-'+ offerkey +'_added').data('avail',availabale_rooms);
                $('#'+ roomtypekey +'-'+ offerkey +'_added').data('meals', alldata[offerkey][roomtypekey].meals);
                $('#'+ roomtypekey +'-'+ offerkey +'_added').data('rooms', alldata[offerkey][roomtypekey].rooms);

                dropdownrowcreator('#' + roomtypekey +'-'+ offerkey +'_added',mealtype);    
            }
        }
        calculationInvalidated();
    }

    function dropdownrowcreator(roomtypeadded,mealtype){

        var mealplanselect = optioncreator(roomtypeadded, 'mealplanselect');
        var roomselect = optioncreator(roomtypeadded, 'roomselect');
        var occuselect = optioncreator(roomtypeadded, 'occuselect');

        $(roomtypeadded).append('&lt;tr class="firstrow"&gt;&lt;td&gt;'+ roomselect +'&lt;/td&gt;&lt;td class="occu"&gt;'+ occuselect +'&lt;/td&gt;&lt;td class="adlt"&gt;&lt;/td&gt;&lt;td class="chld"&gt;&lt;/td&gt;&lt;td class="inft"&gt;&lt;/td&gt;&lt;td&gt;&lt;input type="button" class="button" id='+mealtype+' value="Remove" /&gt;&lt;/td&gt;&lt;/tr&gt;');

        $(roomtypeadded + ' tr.firstrow select.occuselect').change();

        $('tr .firstrow').each(function() {
            var selectedvalue = $(this).find('.roomselect option:selected').val();
            if(selectedvalue &gt; 1) {
                $(this).find('td.occu, td.adlt, td.chld, td.inft').find(':visible').hide();
            }           
        });

    }

    function optioncreator(roomtypeadded,type){

        var result = '';

        if (type == 'roomselect') { 
            result = '&lt;select class="roomselect"&gt;' + numericoptioncreator($(roomtypeadded).data('avail'), true) + '&lt;/select&gt;';
        }
        else if (type == 'mealplanselect') {
            result = '&lt;select class="mealplanselect"&gt;' + mealplanoptioncreator($(roomtypeadded).data('meals')) + '&lt;/select&gt;';
        }
        else if (type == 'occuselect') {
            result = '&lt;select class="occuselect"&gt;' + occuoptioncreator($(roomtypeadded).data('rooms')) + '&lt;/select&gt;';
        }
        else if (type == 'adultselect') {
            result = '&lt;select class="adultselect"&gt;' + numericoptioncreator($(roomtypeadded).data('mxadlt'), true , false , $(roomtypeadded).data('mnadlt')) + '&lt;/select&gt;'; 
        }
        else if (type == 'childselect') { 
            result = '&lt;select class="childselect"&gt;' + numericoptioncreator($(roomtypeadded).data('mxchld')) + '&lt;/select&gt;';
        }
        else if (type == 'infantselect') {
            result = '&lt;select class="infantselect"&gt;' + numericoptioncreator($(roomtypeadded).data('mxinft')) + '&lt;/select&gt;'; 
        }


        return result;
    }


    function mealplanoptioncreator( meals ){
        var result = '';
        if ( meals[0] ) {
            $.each( meals, function(k,val){
                if ( dict[val] ) {
                    result += '&lt;option value="' + val + '"&gt;' + dict[val].vn + '&lt;/option&gt;'
                }
            });
        }
        return result;
    }

    function occuoptioncreator( rooms ){ 

        var result = '';
        if ( rooms ){
            $.each( rooms, function(k,v){
                if( dict[k] ){
                    result += '&lt;option value="' + k + '"&gt;' + dict[k].vn + '&lt;/option&gt;'
                }
            });
        }

        return result;
    }

    function numericoptioncreator(max,nonzero,selected,min){

        var result = '';
        var i = 0;
        if(nonzero){
            i = 1;
        }

        if(min) {
            i = min ;
        }

        var sel = i;
        if( selected ){
            sel = selected;
        }

        for(i; i &lt;= max; i++){
            if ( i == sel ) {
                result += '&lt;option value="' + i + '" selected="selected"&gt;' + i + '&lt;/option&gt;';
            }else{
                result += '&lt;option value="' + i + '"&gt;' + i + '&lt;/option&gt;';
            }
        }
        return result;
    }


    function roomtyperemoved(){
        var roomtypekey = $(this).parents('table').data('roomtypekey')
        var offerkey = $(this).parents('table').data('offerkey');
        var id = $(this).attr('id');

        var sum = 0 ;
        $( $(this).parents('table').find('.firstrow')).each(function() {
            sum += parseInt($(this).find('.roomselect option:selected').text()) ;
        });

        var increment = (parseInt($(this).parents('table').data('cnt')) + parseInt($(this).parents('td').siblings().find('.roomselect option:selected').text()) - sum);     

        $($(this).parents('table').find('.firstrow')).each(function() {
            slected = parseInt($(this).find('.roomselect option:selected').text()); 

            var result = numericoptioncreator((slected+increment),true,slected) ;
            $(this).find('.roomselect').html(result);
         });    

        $(this).parents(".firstrow").prev().remove();
        $(this).parents(".firstrow").prev().remove();       

        while($(this).parents('.firstrow').next().eq(0).attr('class') == 'addrows') {           
            $(this).parents('.firstrow').next().remove();   
        }

        if($(this).parents('tr').siblings().length == 0) {
            $(this).parents('.outer').remove();
            $('#'+ roomtypekey + '_div').hide();
        }

        $(this).parents(".firstrow").remove();                      

        if($('#meal_plan_box tr').length == 0) {

            $('#transport_box').remove();
            $('#calculate_box').empty();
        }

        if($('#room_types_box &gt; div.roomtypediv:hidden').length == $('#room_types_box &gt; div.roomtypediv').length){ 

            $('#room_types_box &gt; div.roomtypediv').show();
            oneroomtypeadded = false;
        }
        $('#'+ roomtypekey +'-'+ offerkey + ' td #'+ id).removeAttr('disabled').removeClass('disabledbutton');
        calculationInvalidated();
    }


    function mealplanselectchanged(){
        calculationInvalidated();
    }

    function roomselectchanged(){

        var tmp = $(this).val();    

        var id = $(this).parents('table').eq(0).attr('id') ;
        var num_of_rooms = $('#'+ id).data('cnt');      
        var row = $(this).parents('.firstrow').siblings('.firstrow'); 
        var sum = 0 ;

        $(row).each(function() {
            sum += parseInt($(this).find('.roomselect option:selected').text());    
         });        

        var increment = (num_of_rooms - tmp) - sum ;

        $(row).each(function() {
            slected = parseInt($(this).find('.roomselect option:selected').text()); 

            var result = numericoptioncreator((slected+increment),true,slected) ;
            $(this).find('.roomselect').html(result);
         });


        var thisrow = $(this).closest('tr'); 
        var header = $(thisrow).prev('tr');     

        if(tmp &gt; 1){    
            $(thisrow).find('td.occu, td.adlt, td.chld, td.inft').find(':visible').hide();
            addperroomdropdownrow(tmp,this);    
        }else{          
            while($(this).parents('.firstrow').next().eq(0).attr('class') == 'addrows') {           
                $(this).parents('.firstrow').next().remove();   
            }

            $(thisrow).find('td.occu, td.adlt, td.chld, td.inft').find(':hidden').show();
        }
        calculationInvalidated();

    }


    function addperroomdropdownrow(rooms,roomselect){
        var row = '';
        var room_table = $(roomselect).closest('table.roomtypeadded');
        var offerkey = $(room_table).data('offerkey');
        var roomtypekey = $(room_table).data('roomtypekey');

        var occuselect = optioncreator(room_table, 'occuselect');

        while($(roomselect).parents('.firstrow').next().eq(0).attr('class') == 'addrows') {         
            $(roomselect).parents('.firstrow').next().remove(); 
        }

        for(i=1;i&lt;=rooms;i++){
            row += '&lt;tr class="addrows"&gt;&lt;td&gt;Room '+ i +'&lt;/td&gt;&lt;td class="occu"&gt;'+ occuselect +'&lt;/td&gt;&lt;td class="adlt"&gt;&lt;/td&gt;&lt;td class="chld"&gt;&lt;/td&gt;&lt;td class="inft"&gt;&lt;/td&gt;&lt;td&gt;&amp;nbsp;&lt;/td&gt;&lt;/tr&gt;';
        }

        $(roomselect).parents('.firstrow').after(row);
        $(room_table).find('tr.addrows select.occuselect').change();
    }


    function occuselectchanged(){
        var thisval = $(this).val();
        var thisrow = $(this).closest('tr');
        var thistable = $(this).closest('table');
        var rooms = $(thistable).data('rooms');
        if( rooms[thisval] ){
            if( !isNaN(rooms[thisval].mxadlt) &amp;&amp; rooms[thisval].mxadlt &gt; 0 ) {
                $(thisrow).find('td.adlt').empty().append('&lt;select class="adultselect"&gt;'+ numericoptioncreator(rooms[thisval].mxadlt,true,false,rooms[thisval].mnadlt) +'&lt;/select&gt;');
            }
            else{
                $(thisrow).find('td.adlt').empty().append('&lt;select class="adultselect"&gt;'+ numericoptioncreator(0) +'&lt;/select&gt;');
            }
            if( !isNaN(rooms[thisval].mxchld) &amp;&amp; rooms[thisval].mxchld &gt; 0 ) { 
                $(thisrow).find('td.chld').empty().append('&lt;select class="childselect"&gt;'+ numericoptioncreator(rooms[thisval].mxchld,false,false,rooms[thisval].mnchld) +'&lt;/select&gt;');
            }
            else{
                $(thisrow).find('td.chld').empty().append('&lt;select class="childselect"&gt;'+ numericoptioncreator(0) +'&lt;/select&gt;');
            }
            if( !isNaN(rooms[thisval].mxinft) &amp;&amp; rooms[thisval].mxinft &gt; 0 ) {
                $(thisrow).find('td.inft').empty().append('&lt;select class="inftselect"&gt;'+ numericoptioncreator(rooms[thisval].mxinft,false) +'&lt;/select&gt;');
            }else{
                $(thisrow).find('td.inft').empty().append('&lt;select class="inftselect"&gt;'+ numericoptioncreator(0) +'&lt;/select&gt;');
            }
            $(thisrow).find('select.adultselect').change();
        }

        calculationInvalidated();
    }


    function adultselectchanged(){

        var val = $(this).val(); 

        var tablerow = $(this).closest('tr');
        var rooms = $(this).closest('table.roomtypeadded').data('rooms');
        var occuselectval = $(tablerow).find('select.occuselect').val();
        var occu = 0;
        var mxchld = 0;
        var additionallogical = 0;

        if( rooms[occuselectval] &amp;&amp; rooms[occuselectval].mxadlt &amp;&amp; rooms[occuselectval].mxchld ){
            occu = rooms[occuselectval].mxadlt;
            mxchld = rooms[occuselectval].mxchld; 
            additionallogical = rooms[occuselectval].addchild;
        }

        var childavail = ( occu - val ) * 2 + parseInt(additionallogical); // account for child being 0.5 of an adult 

        var adultselect = $(this).closest('tr').find('select.adultselect');
        var childselect = $(this).closest('tr').find('select.childselect');
        var inftselect = $(this).closest('tr').find('select.inftselect');

        var tmp = 0;

        if((parseInt(mxchld) + parseInt(additionallogical)) &gt; childavail){
            tmp = childavail; 
        }else{
            tmp = parseInt(mxchld) + parseInt(additionallogical); 
        }

        if(rooms[occuselectval].mnchld &gt; tmp) {
            tmp = rooms[occuselectval].mnchld;
        }

        if (childselect.find('option:last').val() != tmp) {
            var sel_val = childselect.find('option:selected').val();
            childselect.find('option').remove();
            childselect.append(numericoptioncreator(tmp, false,false,rooms[occuselectval].mnchld));
            if(sel_val &lt;= tmp){
                childselect.find('option').each(function(){
                    if($(this).val() == sel_val){
                        $(this).attr('selected','selected');
                    }
                });
            }
        }

        inftselect.find('option').remove();
        inftselect.append(numericoptioncreator(rooms[occuselectval].mxinft, false,false,rooms[occuselectval].mninft));

        calculationInvalidated();
    }


    function childselectchanged(){
        var val = $(this).val();
        var tablerow = $(this).closest('tr');
        var rooms = $(this).closest('table.roomtypeadded').data('rooms');
        var occuselectval = $(tablerow).find('select.occuselect').val();
        var occu = 0;
        var mxadlt = 0;
        var additionallogical = 0;

        if( rooms[occuselectval] &amp;&amp; rooms[occuselectval].mxadlt ){
            occu = rooms[occuselectval].mxadlt;
            mxadlt = rooms[occuselectval].mxadlt; 
            additionallogical = rooms[occuselectval].addchild;
            val = val - additionallogical ;
        }       

        var avail = Math.floor(occu - (val / 2)); // to account for a child being 0.5 of an adult
        var adultselect = $(this).parent().prev('td.adlt').find('select.adultselect');

        var tmp = 0;
        if(mxadlt &gt; avail){
            tmp = avail;
        }else{
            tmp = mxadlt;
        }

        if(rooms[occuselectval].mnadlt &gt; tmp) {
            tmp = rooms[occuselectval].mnadlt;
        }


        if (adultselect.find('option:last').val() != tmp) {
            var sel_val = adultselect.find('option:selected').val();
            adultselect.find('option').remove();
            adultselect.append(numericoptioncreator(tmp, true,false ,rooms[occuselectval].mnadlt));
            if(sel_val &lt;= tmp){
                adultselect.find('option').each(function(){
                    if($(this).val() == sel_val){
                        $(this).attr('selected','selected');
                    }
                });
            }
        }

        calculationInvalidated();
    }

    function inftselectchanged(){
        calculationInvalidated();
    }


    function calculaterate(){

        $('#calculate_box input[type=button]').attr('disabled','disabled');
        $('#calculate_box input[type=button]').addClass('disabledbutton');

        var obj = selectedrooms();

        var str = JSON.stringify(obj);

        $('body').css('cursor','progress');

        $.post('/rooms/calc', { data: str }, function(data){

            $('#result').empty();
            $('#result').append('&lt;table class="outer"&gt;&lt;thead&gt;&lt;tr&gt;&lt;th&gt;Rates&lt;/th&gt;&lt;/tr&gt;&lt;/thead&gt;&lt;tr&gt;&lt;td class="td_bg"&gt;&lt;table id="rates"&gt;&lt;/table&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;');

            calculated = data;
            if (calculated.offers) {
                var curr = '';
                if( calculated.offers.rate &amp;&amp; calculated.offers.rate.curr ) {
                    curr = calculated.offers.rate.curr.toString();
                }
                $.each(calculated.offers, function(offercode, roomtypes){
                    if (offercode != 'rate' &amp;&amp; dict[offercode]) {
                        $('#rates').append('&lt;tr class="offer"&gt;&lt;td class="bold" colspan="3"&gt;' + dict[offercode].vn + '&lt;/td&gt;&lt;/tr&gt;');
                        $.each(roomtypes, function(roomcode, roomdata){
                            if (roomcode != 'rate' &amp;&amp; dict[roomcode] &amp;&amp; roomdata.rate &amp;&amp; roomdata.rate.hasOwnProperty('sum')) {
                                $('#rates').append('&lt;tr&gt;&lt;td class="wid70"&gt;' + dict[roomcode].vn + '&lt;/td&gt;&lt;td class="cost"&gt;'+ curr +'&lt;/td&gt;&lt;td class="cost"&gt;' + roomdata.rate.sum + '&lt;/td&gt;&lt;/tr&gt;');
                            }
                        });
                    }
                });

                if (calculated.offers &amp;&amp; calculated.offers.rate &amp;&amp; calculated.offers.rate.hasOwnProperty('sum') &amp;&amp; calculated.offers.rate.hasOwnProperty('tax') &amp;&amp; calculated.offers.rate.hasOwnProperty('total')
                        &amp;&amp; calculated.offers.rate.hasOwnProperty('trans') &amp;&amp; calculated.offers.rate.hasOwnProperty('trans_total')) {
                    $('#rates').append('&lt;tr class="borderbottom"&gt;&lt;td colspan="3"&gt;&lt;/td&gt;&lt;/tr&gt;');
                    $('#rates').append('&lt;tr&gt;&lt;td class="wid70 bold"&gt;Total Room Rates&lt;/td&gt;&lt;td class="cost"&gt;'+ curr +'&lt;/td&gt;&lt;td class="cost"&gt;' + calculated.offers.rate.sum + '&lt;/td&gt;&lt;/tr&gt;');
                    $('#rates').append('&lt;tr&gt;&lt;td class="wid70 bold"&gt;Taxes&lt;/td&gt;&lt;td class="cost"&gt;'+ curr +'&lt;/td&gt;&lt;td class="cost"&gt;' + calculated.offers.rate.tax + '&lt;/td&gt;&lt;/tr&gt;');
                    $('#rates').append('&lt;tr class="borderbottom"&gt;&lt;td colspan="3"&gt;&lt;/td&gt;&lt;/tr&gt;');
                    $('#rates').append('&lt;tr class="offer"&gt;&lt;td class="wid70 bold"&gt;Sub total&lt;/td&gt;&lt;td class="cost"&gt;'+ curr +'&lt;/td&gt;&lt;td class="cost"&gt;' + calculated.offers.rate.total + '&lt;/td&gt;&lt;/tr&gt;');
                    $('#rates').append('&lt;tr&gt;&lt;td class="wid70 bold"&gt;Transport&lt;/td&gt;&lt;td class="cost"&gt;'+ curr +'&lt;/td&gt;&lt;td class="cost"&gt;' + calculated.offers.rate.trans + '&lt;/td&gt;&lt;/tr&gt;');
                    $('#rates').append('&lt;tr class="borderbottom"&gt;&lt;td colspan="3"&gt;&lt;/td&gt;&lt;/tr&gt;');
                    $('#rates').append('&lt;tr class="offer"&gt;&lt;td class="wid70 bold"&gt;Total&lt;/td&gt;&lt;td class="cost"&gt;'+ curr +'&lt;/td&gt;&lt;td class="cost"&gt;' + calculated.offers.rate.trans_total + '&lt;/td&gt;&lt;/tr&gt;');
                    $('#result').append('&lt;div class="floatleft"&gt;&lt;span id="daily"&gt;Daily Rates Breakdown &amp;gt;&amp;gt;&lt;/span&gt;&lt;/div&gt;');
                    $('#result').append('&lt;div class="floatright"&gt;&lt;form id="proceedform" method="post" action="/guest"&gt;&lt;input class="hidden" type="hidden" name="data" &gt;&lt;input id="proceed" class="button" type="submit" value="Proceed" /&gt;&lt;/form&gt;&lt;/div&gt;&lt;div class="clearboth"&gt;&lt;/div&gt;');
                    $('#daily').click(showCalendar);
                    $('#proceedform').submit(proceedClicked);
                    $('body').css('cursor','auto');

                }

            }

        },"json");

    }


    function selectedrooms(){
        var obj = {};
        $('#meal_plan_box table.outer table.roomtypeadded').each(function(){
            var offerkey = $(this).data('offerkey');
            if(!obj[offerkey]){
                obj[offerkey] = {}; 
            }
            var roomkey = $(this).data('roomtypekey');
            if(!obj[offerkey][roomkey]){
                obj[offerkey][roomkey] = {};
            }
            var mealplan = $(this).find('tr.firstrow select.mealplanselect').val();

            if($(this).find('tr.addrows').length &gt; 0){
                var tmp = $(this).find('tr.addrow').length;
                var i = 0;
                $(this).find('tr.addrows').each(function(){
                    obj[offerkey][roomkey][i] = {};
                    obj[offerkey][roomkey][i]['M'] = mealplan;
                    obj[offerkey][roomkey][i]['O'] = $(this).find('td.occu select.occuselect').val();
                    obj[offerkey][roomkey][i]['A'] = $(this).find('td.adlt select.adultselect').val();
                    obj[offerkey][roomkey][i]['C'] = $(this).find('td.chld select.childselect').val();
                    obj[offerkey][roomkey][i]['I'] = $(this).find('td.inft select.inftselect').val();
                    i++;
                });

            }else{
                obj[offerkey][roomkey][0] = {};
                obj[offerkey][roomkey][0]['M'] = mealplan;
                obj[offerkey][roomkey][0]['O'] = $(this).find('td.occu select.occuselect').val();
                obj[offerkey][roomkey][0]['A'] = $(this).find('tr.firstrow td.adlt select.adultselect').val();
                obj[offerkey][roomkey][0]['C'] = $(this).find('tr.firstrow td.chld select.childselect').val();
                obj[offerkey][roomkey][0]['I'] = $(this).find('tr.firstrow td.inft select.inftselect').val();
            }

        });

        var transportval = 0;

        if($('#air-trans-yes').attr('checked')){
            transportval = 1;
        }

        if(!obj.hasOwnProperty('transport')){
            obj.transport = transportval;
        }

        return obj;
    }


    function showCalendar(){
        $('body').prepend('&lt;div id="overlay"&gt;&lt;/div&gt;');
        if($.browser.msie &amp;&amp; $.browser.version=="6.0"){
            $('#overlay').append('&lt;iframe&gt;&lt;/iframe&gt;');
        }
        $('#overlay').height($(document).height());
        $('body').append('&lt;div id="popupwrapper"&gt;&lt;div id="calendar"&gt;&lt;/div&gt;&lt;/div&gt;');

        if (calculated.calendar) {
            $('#calendar').emeCalendar(calculated.calendar);
        }

        $('#calendar div.header div.clearboth').before('&lt;span class="close"&gt;Close&lt;/span&gt;');

        $('#calendar div.header span.close').click(function(){
            $('#overlay').remove();
            $('#popupwrapper').remove();
        });

    }

    function proceedClicked(){
        var obj = selectedrooms();
        var str = JSON.stringify(obj);

        $('#proceedform input[type="hidden"]').val(str);
        return true;

    }

    function calculationInvalidated(){
        $('#result').empty();   
        $('#calculate_box input[type="button"]').removeAttr('disabled', 'disabled');
        $('#calculate_box input[type="button"]').removeClass('disabledbutton');
    }

})(jQuery);
</code></pre>
