As you can see in the code below, I have 2 flags my and hk.
When I click on the hk flag, it will redirect to the hk page and at the same time will disable the hk button to show the difference from other buttons.
So,what php code do I use to disable only the button that is clicked?
<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>
You could read the
$_SERVER['REQUEST_URI']and disable the button if it links to the current page. Example:You might want to
trim($uri, '/')andtrim($_SERVER['REQUEST_URI'], '/')there to make sure there are no mistakes with slashes.You could also append a
$_GETvariable to the link like?country_code=hkand read that instead:There, you should also make sure to check if
isset($_GET['country_code']), and any other links on the page would most likely have to use the query string as well. I was trying to make this readable. I would just write a function for reading the url personally.I prefer the first approach. Sorry, I had to craft it in my coding style, but hopefully you get the idea and this works for you.