2012-07-01 33 views
0

我想知道是否有人可以帮助我。通过URL将PHP变量传递给外部表格

我捕获Session variable HTML表格内,如下所示:

$lid = $_SESSION['lid']; 

从这个主HTML形式,使用下面的代码行,我然后加载使用“mysqlajaxtableeditor`软件的外部AJAX表:

</script> 
<!-- Set ajax url --> 
     <script type="text/javascript"> 
      trackHistory = false; 
      var ajaxUrl = 'Example3.php'; 
     </script> 

<body id="page2" onload="toAjaxTableEditor('update_html','');"> 

我想什么能够做的,就是从主窗体捕获Session variable并将其传递到外部AJAX表。

我已经阅读了本网站上的许多帖子,我希望能够解决我的问题,但我似乎无法将价值传递给对方。

从我读过,我已经尽我的主要形式如下: var ajaxUrl = 'Example3.php?lid=$lid';,然后在接收AJAX表脚本,$lid = $_GET['lid'];但它不工作,我不知道在哪里,我出错了。

有关其他信息,我已经张贴下面的AJAX表的代码:

class Example1 extends Common 
{ 
    function initiateEditor() 
    { 
     $tableColumns['findid'] = array('display_text' => 'Find ID', 'perms' => 'TV'); 
     $tableColumns['dateoftrip'] = array('display_text' => 'Date of Trip', 'perms' => 'ETV'); 
     $tableColumns['finddescription'] = array('display_text' => 'Find Description', 'perms' => 'ETV'); 
     $tableColumns['detectorname'] = array('display_text' => 'Detector Used', 'perms' => 'EVT'); 
     $tableColumns['searchheadname'] = array('display_text' => 'Search Head Used', 'perms' => 'ETV'); 
     $tableColumns['pasref'] = array('display_text' => 'PAS Ref.', 'perms' => 'ETV'); 

     $tableName = 'finds'; 
     $primaryCol = 'findid'; 
     $errorFun = array(&$this,'logError'); 
     $permissions = 'EID'; 

     require_once('php/AjaxTableEditor.php'); 
     $this->Editor = new AjaxTableEditor($tableName,$primaryCol,$errorFun,$permissions,$tableColumns); 
     $this->Editor->setConfig('tableInfo','cellpadding="1" width="800" class="mateTable"'); 
     $this->Editor->setConfig('tableTitle',''); 
     $this->Editor->setConfig('orderByColumn','dateoftrip'); 
     $this->Editor->setConfig('editRowTitle','Edit Details'); 
     $this->Editor->setConfig('iconTitle','Edit Find Details'); 
    } 


    function Example1() 
    { 
     if(isset($_POST['json'])) 
     { 
     session_start(); 
     $this->mysqlConnect(); 
     if(ini_get('magic_quotes_gpc')) 
     { 
      $_POST['json'] = stripslashes($_POST['json']); 
     } 
     if(function_exists('json_decode')) 
     { 
      $data = json_decode($_POST['json']); 
     } 
     else 
     { 
      require_once('php/JSON.php'); 
      $js = new Services_JSON(); 
      $data = $js->decode($_POST['json']); 
     } 
     if(empty($data->info) && strlen(trim($data->info)) == 0) 
     { 
      $data->info = ''; 
     } 
     $this->initiateEditor(); 
     $this->Editor->main($data->action,$data->info); 
     if(function_exists('json_encode')) 
     { 
      echo json_encode($this->Editor->retArr); 
     } 
     else 
     { 
      echo $js->encode($this->Editor->retArr); 
     } 

     } 
    } 
} 
$lte = new Example1(); 
?> 

我只是想知道一个人是否有可能看这个,请让我knwo我要去哪里错了吗?

许多的感谢和亲切的问候

+0

我没有understend,但你可以使用一个Ajax风格的subitting:如$。员额... VAR1,VAR2,VAR3到Example3.php –

+0

它添加到文件名是正确的做法。但是我们无法知道您的AJAX或表格文件加载方法(均未显示)是否再次除去参数(如果添加了默认的GET参数)。 – mario

+0

嗨@mar​​io,呃你这个,我的道歉,省略表代码。我现在已将此添加到我原来的帖子中。亲切的问候 – IRHM

回答

0

大量的工作后,并在网上搜索,我找到了解决办法。

在HMTL页我写这样的:

<!-- Set ajax url --> 
     <script type="text/javascript"> 
      trackHistory = false; 
      var ajaxUrl = 'ajaxtable.php?lid=$lid'; 
     </script> 
<body id="page2" onload="toAjaxTableEditor('update_html','');"> 

在我接受AJAX表编辑软件脚本我写道:

function initiateEditor() 
{ 
    $tableColumns['locationid'] = array('display_text' => '', 'perms' => '','data_filters' => array('filters' => array("='".$_SESSION['lid']."'")), 'default' => $_SESSION['lid']); 

我希望这可以帮助别人的未来。

亲切的问候