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();
}

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

帮我。

4

3 回答 3

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();
}
于 2013-04-16T09:34:56.010 回答
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();
}
于 2013-04-16T09:28:45.677 回答
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';
    }
}
于 2015-10-31T05:13:38.247 回答