单击时禁用按钮

| 如下面的代码所示,我有2个标记ѭ0flag和
hk
。 当我单击
hk
标志时,它将重定向到
hk
页面,同时将禁用
hk
按钮以显示与其他按钮的区别。 那么,我该使用什么php代码来仅禁用所单击的按钮?
<button id=\"btn_my\" dojoType=\"dijit.form.Button\" 
  onClick=\'location = \"<?php echo url_realurl();?>/results/view/all/M\"\'>
<?php 
  echo ci_create_img(\'my\');
?> <!--this is malaysia flay image -->
</button>
<button id=\"btn_hk\" dojoType=\"dijit.form.Button\" 
  onClick=\'location = \"<?php echo url_realurl();?>/results/view/all/H\"\'>
<?php 
  echo ci_create_img(\'hk\');
?><!--this is hongkong flay image-->
</button>
    
已邀请:
        如果链接到当前页面,您可以阅读ѭ6并禁用该按钮。例:
<?php
$countries = array(
    \'my\'    =>  \'/results/view/all/M\',
    \'hk\'    =>  \'/results/view/all/H\',
);
?>

<?php foreach ($countries as $code => $uri): ?>

    <?php if ($_SERVER[\'REQUEST_URI\'] === $uri): ?>
    <button class=\"disabled\">
    <?php else: ?>
    <button onClick=\'location=\"<?php echo url_realurl().$uri; ?>\"\'>
    <?php endif; ?>
        <?php echo ci_create_img($code);?>
    </button>

<?php endforeach; ?>
您可能想要在
trim($uri, \'/\')
trim($_SERVER[\'REQUEST_URI\'], \'/\')
那里确保没有斜杠错误。 您还可以在链接中附加
$_GET
变量,例如
?country_code=hk
,并改为阅读:
<?php foreach ($countries as $code => $uri): ?>

    <?php if ($_GET[\'country_code\'] === $code): ?>
    <button class=\"disabled\">
    <?php else: ?>
    <button onClick=\'location=\"<?php echo url_realurl().$uri.\'?country_code=\'.$code; ?>\"\'>
    <?php endif; ?>
        <?php echo ci_create_img($code);?>
    </button>

<?php endforeach; ?>
在那里,您还应该确保检查ѭ13,并且页面上的任何其他链接也很有可能也必须使用查询字符串。我试图使它可读。我只是编写一个用于个人阅读url的函数。 我更喜欢第一种方法。抱歉,我必须以我的编码方式来制作它,但希望您能理解,并且对您有用。     

要回复问题请先登录注册