Manoranjan Jena
Manoranjan Jena

Reputation: 79

How to send a javascript dynamic data to php variable using extjs url?

I have list of links in one page which is dynamically created. I want to do when I click on one link another page will be open and according to link id which is i am sending the data will be fetch from database and load into a pagination ext data grid.

Bellow in my Javascript code

     var extGrid = null;
     var center_data_store=null;
     var exam_id = null;
     Ext.onReady(function(){

// create the data store
exam_id = document.getElementById("hdnExamId").value;  


//I am getting id from one hidden field.  

//alert(exam_id);// Id is coming.  

 multiple_choice_all_data_store = new Ext.data.JsonStore({
    totalProperty: 'total', // total data, see json output
    root: 'results',    // see json output  

    url: 'multiple_choice_all_data_grid.php"?exm_id="+exam_id',  
       //in above url I am passing data.


    fields: [
        {name: 'OEXM_Id', type: 'int'},
        'OEXM_txtareaQuestion','OEXM_rbtnOption','OEXM_txtOption1','OEXM_txtOption2','OEXM_txtOption3','OEXM_txtOption4','OEXM_txtExamId','OEXM_txtExamName'
        ]
});

// load data from the url ( data.php )
multiple_choice_all_data_store.load({params:{start: 0, limit: 15}});

// create the Grid
var multiplechoicealldataGrid = new Ext.grid.GridPanel({
    store: multiple_choice_all_data_store,
    columns: [
        new Ext.grid.RowNumberer(),
        //{header: 'ID', width: 30, sortable: true, dataIndex: 'OEXM_Id',hidden:false},
        {header: 'Question', width: 300, sortable: true, dataIndex: 'OEXM_txtareaQuestion',hidden:false},
        {header: 'Answer', width: 100, sortable: true, dataIndex: 'OEXM_rbtnOption',hidden:false},
        {header: 'Option1', width: 100, sortable: true, dataIndex: 'OEXM_txtOption1',hidden:false},
        {header: 'Option2', width: 100, sortable: true, dataIndex: 'OEXM_txtOption2',hidden:false},
        {header: 'Option3', width: 100, sortable: true, dataIndex: 'OEXM_txtOption3',hidden:false},
        {header: 'Option4', width: 100, sortable: true, dataIndex: 'OEXM_txtOption4',hidden:false}

    ],
    stripeRows: true,
    height:470,
    width:792,
    title:'All Multiple Choice Question Information',
    bbar: new Ext.PagingToolbar({
        pageSize: 15,
        store: multiple_choice_all_data_store,
        displayInfo: true,
        displayMsg: 'Displaying Records {0} - {1} of {2}',
        emptyMsg: "No topics to display"
    })

});

My problem is I am not able to get ID value in my PHP Page.

Upvotes: 0

Views: 832

Answers (2)

A1rPun
A1rPun

Reputation: 16837

To get a element in ExtJS:
exam_id = Ext.getCmp("hdnExamId").getValue();
The getValue() method is used to retrieve the value of the element.

Edit:
Also fix the url @Lolo is pointing out.

Upvotes: 0

Krzysztof
Krzysztof

Reputation: 16130

Try change url in the store definition to 'multiple_choice_all_data_grid.php?exm_id='+exam_id

Then your id should be available in PHP in $_GET['exm_id'] variable

Upvotes: 2

Related Questions