我是初学者并且有问题。我有一个数据库,我正在使用日期和功能,我在每个产品页面上生成链接。当您单击带有链接的按钮时,我想在弹出窗口中打开它。我的问题是我不知道如何连接JavaScript和这个函数,因为PHP在服务器上运行,而在浏览器上运行JavaScript。这是URL生成器的代码
global $currentLanguage;
global $currentTag;
function low($name_certificate) {
//Lower case everything
$name_certificate = strtolower($name_certificate);
//Convert whitespaces and underscore to dash
$name_certificate = preg_replace("/[\s_]/", "-", $name_certificate);
return $name_certificate;
}
$currentLanguage = JFactory::getLanguage();
$currentTag = $currentLanguage->get('tag');
function lang($currentTag) {
global $lang;
if ($currentTag=='en-GB') { $lang='en'; }
elseif ($currentTag=='cs-CZ') { $lang='cz'; }
elseif ($currentTag=='el-GR') { $lang='gr'; }
elseif ($currentTag=='hu-HU') { $lang='hu'; }
elseif ($currentTag=='pl-PL') { $lang='pl'; }
elseif ($currentTag=='ro-RO') { $lang='ro'; }
elseif ($currentTag=='sk-SK') { $lang='sk'; }
elseif ($currentTag=='tr-TR') { $lang='tr'; }
elseif ($currentTag=='bg-BG') { $lang='bg'; }
return $lang;
}
function urlGenerator($company,$name_certificate){
global $currentLanguage;
$ssl='http://example.com';
$lang=lang($currentLanguage);
$company=low($company);
$name_certificate=low($name_certificate);
$link=$ssl.'/'.$lang.'/'.$company.'/'.$name_certificate;
return $link;
} `
所有连接都正常。 这是我有按钮的表的代码,需要打开而不是在difernet窗口而是弹出窗口。这个按钮是一个循环acordingwith产品:
foreach($row as $key => $price){ ?>
<tr id="price"style="font:15px,arial,sans-serif;font-weight:bold; text-align:center;">
<td style=""><?= $price['year']; if ($price['year']==1 ) {echo 'year'; } else {echo 'years';} ?><br>
<?= round($price['margin']*$price['buy_price']*$value,$round); echo " ",$currency_sign;?></span></h5></td>
<td><?php echo 'per_year';?>
<?= round((($price['margin']*$price['buy_price'])/$price['year'])*$value,$round);echo " ",$currency_sign;?></span></td>
<td><a href="<?php echo buy($idCert,$price['year']); ?> " target="_blank"><button type="submit"><img src="images/icons/shop_cart.png" style="vertical-align:middle;"><?php echo 'buy';?></button></a></td></tr>
}