download2565
2012-09-27 07:37
浏览 30
已采纳

如何在javascript中将组合框(EXTJS)中的参数传递给php文件?

First I declared an Ext.form.ComboBox which name is leventcombo and also I created a store Ext.data.JsonStore its name is leventstore. I can reach the php file and the data can return the javascript. But I cannot pass id value to the php file. how can I send it?

var leventcombo = new Ext.form.ComboBox({
    store: leventstore,// call jsonstore
    fieldLabel: '',
    minChars: 2,
    width:50,
    displayField:'isim',
    valueField: 'isim',
    typeAhead: false,
    loadingText: dil('Aranıyor...'),
    hideTrigger:true, 
    tpl: template1,
    emptyText: dil('levo ...'),
    itemSelector: 'div.search-item',
    name: 'leventwindeneme',
    id: 'leventwindenemeID',
    anchor: '100%',
    allowBlank:false,
    listeners:{
       beforequery: function(){
       }   
    }            
});


var leventstore = new Ext.data.JsonStore({
    totalProperty: 'results',
    root: 'rows',
    id: 'id',
    proxy: new Ext.data.HttpProxy({
       url: 'phps/leventstore.php?lang=dil(lang)'
    }),
    fields: [
    {
       ///phpden dönen veriler
       name:'id'
    },{
       ///phpden dönen veriler
       name:'isim'
    }]
});

leventstore.php:

<?php
include_once("kutuphane/inc.php");
$sql="select id, isim  from levent";
$_SESSION["VT"]->doQuery($sql);
$donecek = $_SESSION["VT"]->arrayYapVer();

$veriler=array();
if (sizeof($donecek) > 0) {
    foreach ($donecek as $file) {
        $tempFi = array();
        $tempFi = array(
            "id" => $file["id"],
            "isim" => $file["isim"]

        );
        array_push($veriler, $tempFi);
    }
}
$donecek = array("results" => (sizeof($donecek)), "success" => "true", "rows" => $veriler);
echo json_encode($donecek);
?>

图片转代码服务由CSDN问答提供 功能建议

首先我声明了一个Ext.form.ComboBox,其名称是leventcombo,我还创建了一个商店Ext.data.JsonStore 它的名字是leventstore。 我可以到达php文件,数据可以返回javascript。 但是我无法将id值传递给php文件。 我该如何发送?

  var leventcombo = new Ext.form.ComboBox({
 store:leventstore,// call jsonstore 
 fieldLabel:'',
  minChars:2,
 width:50,
 displayField:'isim',
 valueField:'isim',
 typeAhead:false,
 loadingText:dil('Aranıyor...'),
 hideTrigger:  true,
 tpl:template1,
 emptyText:dil('levo ...'),
 itemSelector:'div.search-item',
 name:'leventwindeneme',
 id:'leventwindenemeID',  
 anchor:'100%',
 allowBlank:false,
 listeners:{
 beforequery:function(){
} 
} 
}); 
 
 
var leventstore = new Ext。  data.JsonStore({
 totalProperty:'results',
 root:'rows',
 id:'id',
 proxy:new Ext.data.HttpProxy({
 url:'phps / leventstore。  php?lang = dil(lang)'
}),
字段:[
 {
 ///phpdendönenveriler
 name:'id'
},{
 ///phpdendönenveriler  
名称:'isim'
}] 
}); 
   
 
 

leventstore.php:

&lt;?php include_once(“kutuphane / inc.php”); $ sql =“select id,isim from levent”; $ _SESSION [“VT”] - &gt; doQuery($ sql); $ donecek = $ _SESSION [“VT”] - &gt; arrayYapVer(); $ veriler = array(); if(sizeof($ donecek)&gt; 0){ foreach($ donecek as $ file){ $ tempFi = array(); $ tempFi = array( “id”=&gt; $ file [“id”], “isim “=&gt; $ file [”isim“] ); array_push($ veriler,$ tempFi); } } $ donecek = array(”results“=&gt;(sizeof( $ donecek)),“success”=&gt;“true”,“rows”=&gt; $ veriler); echo json_encode($ donecek); ?&gt;

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

1条回答 默认 最新

  • douzhulan1815 2012-09-27 12:08
    最佳回答

    Take a look here: http://docs.sencha.com/ext-js/4-1/#!/api/Ext.Ajax-cfg-extraParams

    You should use 'params' config option.

    If you want to load store manually, use the following:

    leventstore.proxy.extraParams.id = your_id;
    leventstore.load();
    
    评论
    解决 无用
    打赏 举报

相关推荐 更多相似问题