简体   繁体   English

Joomla-使用Ajax从复选框创建会话变量

[英]Joomla - Create session variable from checkbox with ajax

I'm trying to create a session variable joomla style with ajax when checkboxes are selected. 当选中复选框时,我正在尝试使用ajax创建会话变量joomla样式。 Here is my code in the select_thumb.ajax.php file: 这是我在select_thumb.ajax.php文件中的代码:

$_SESSION['ss'] = $value;
$response = $_SESSION['ss'];
echo $response;

}
exit;
// Get db connection
$db = JFactory::getDbo();
//create new query object
$query = $db->getQuery(true);

//Prepare insert query
$query
    ->insert($db->valueChbx('download_variable'))

// Set the query using populated query object and execute it.
$db->setQuery($query);
$db->execute();
?>

Here is my HTML for the checkboxes: 这是复选框的我的HTML:

<input type="checkbox" id="thumbselect" name="valueChbx" class="checkbox" value="/import/images/'+data[i]['filename']+'">';

I haven't coded the ajax through javascript yet because I'm wondering if i should use onFocus? 我还没有通过javascript编码ajax,因为我想知道是否应该使用onFocus? There could be multiple checkboxes selected. 可能选中了多个复选框。 Thanks for any help in advance. 感谢您的任何帮助。

Do not use PHP's default session variable in Joomla application use its native factory for that. 不要在Joomla应用程序中使用PHP的默认会话变量,而应使用其本机工厂。

Set a session variable 设置会话变量

$session = JFactory::getSession();
$session->set('name', "value");

Get a session variable 获取会话变量

$session = JFactory::getSession();
echo $session->get('name');

more . 更多

hope it helps.. 希望能帮助到你..

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM