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
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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.