如何在JRoute()中使用javascript变量?

时间:2013-04-16 09:25:31

标签: php javascript jquery joomla joomla2.5

function getProduct(category)
{
    document.galaxy.action = '<?php echo JRoute::_('index.php?option=com_virtuemart&view=category&virtuemart_category_id='+ category) ?>';
    document.getElementById('galaxy').submit();
}

如何在JRoute中使用JavaScript变量“(category)”。

帮助我。

3 个答案:

答案 0 :(得分:0)

function getProduct(category)
{
    document.galaxy.action = '<?php echo JRoute::_("index.php?option=com_virtuemart&view=category&virtuemart_category_id="'+ category+') ?>';
    document.getElementById('galaxy').submit();
}

答案 1 :(得分:0)

尝试在php末尾连接,并注意引号"

function getProduct(category){
    document.galaxy.action = "<?php echo JRoute::_('index.php?option=
        com_virtuemart&view=category&virtuemart_category_id='"+category+"') ?>";
    document.getElementById('galaxy').submit();
}

答案 2 :(得分:0)

function deleteItem() {
    var item_id = jQuery(this).attr('data-item-id');
    if (confirm("<?php echo JText::_('COM_CN_REPORTS_DELETE_MESSAGE'); ?>")) {
        window.location.href = '<?php echo JRoute::_("index.php?option=com_cn_reports&task=commoverrideform.remove&id='%2Bitem_id%2B'", false, 2); ?>';
    }
}

在浏览器中格式化为

function deleteItem() {
    var item_id = jQuery(this).attr('data-item-id');
    if (confirm("Are you sure that you want delete this item?")) {
        window.location.href = 'http://cnbeta2.me/index.php?option=com_cn_reports&task=commoverrideform.remove&id='+item_id+'&Itemid=262';
    }
}