Jump to content

disabling a hyperlink


spartin20

Recommended Posts

Hello,

 

I'm got a bit of a weird one here.

 

I have a hyperlink on my page which I want to diasble (ie: be not clickable") when a value returned from the MySql database is more than 60. 

 

The scenario is that I have a tutorial system, and when my students get over 60% in a module, it doesn't let them back in to access it again.  The modules are all displayed as hyperlinks on the index page and I want to make them unclickable if they get over 60%. 

 

I'm grand getting the values from the MySql database, but just need to know how to make the hyperlink links unclickable in php using their ID.  I tried making the <a href = "#"> but that still makes it clickable!!

 

Thanks in advance.

 

Steve

Link to comment
https://forums.phpfreaks.com/topic/95199-disabling-a-hyperlink/
Share on other sites

create a javascript function that do nothing

 

<script>
function nothing() {
// nothing here
}
</script>

 

and replace the hyperlink with javascript:nothing();

 

<a href="javascript:nothing();">link</a>

 

this will make the link, clickable and saves the links style too, but nothing will happen when clicked

Link to comment
https://forums.phpfreaks.com/topic/95199-disabling-a-hyperlink/#findComment-487619
Share on other sites

will this will make you go for removing the <a href=""> + </a> from the link, here you may want to go for regex unless the links there are printed in php, in the later case it's just an if condition

 

if ($mark>=60) {
echo "normal text";
}else{
echo "<a href=\"hyperlink\">link text</a>";
}

 

about that regex, I know some basic but I think the regex forum will be much helper

 

but as thorpe said, post the code if you want more specific help

Link to comment
https://forums.phpfreaks.com/topic/95199-disabling-a-hyperlink/#findComment-487630
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.