jqueryhtmliframejquery-easyuidatebox

How to get easyui datebox content if it is placed inside Iframe


I tried with the below code to access easyui datebox content placed inside Iframe and it doesn't succeed.

alert($("#documentFrame").contents().find("#field6").datebox('getValue');

Where #documentFrame is Iframe ID and #field6 ID if the datebox.

Getting the value of text boxes is working fine with the following code.

alert($("#documentFrame").contents().find("#field2").val());

Where #documentFrame is Iframe ID and #field2 ID if the inputbox.

How could I to get datebox value ?


Solution

  • To accomplish the process of getting datebox content which is placed inside Iframe you can follow this:

    You need to write function as below in your iframe document which returns datebox value.

    Code

    function getValue(value){
        var id='#'+value;
        var val= $(id).datebox('getValue');
        return val;
    }
    

    From parent document you can call getValue() method and pass datebox component ID as argument to the getValue() method.

    Code to call getValue() from Iframe parent document

    value = window.frames[0].getValue('field ID');
    alert(value);
    

    Thank you