Hi, I'm fairly new to HTML & scripting. I need to disable a " a href link" on a particular condition. I tried using "disabled" property.It just grays out the link and the link can still be clicked. I want to make it non-clickable.Is there a way to do this? Please help..
I think if you put an onclick on the link and just return false it'll do it. Put your condition in the onclick event and if the condition fails just return false.
Sorry..It doesn't work. Basically I'm able to click the link and it takes me to another page. I don't want that to happen. Actually I want the link to be deactivated on meeting the condition. do I need to set some property to false..?
I tried simply making a link and putting return false in the onclick and it worked. Post the href line you're using so we can take a look. Return false will cancel out the click.
<a href="knv.jsp" onklick="clicked()" >Known Values"<a/>" replaced c with k in onclick I had problems posting this message I put the condition inside clicked()as you said. Pls give me the correct format with an example.
Where you call the clicked() method before that put return. If in the function you say return false then that will be returned for the function only. The return I mention here is the return to the click event. So, therefore klicked="return clicked();". In the function to cancel the click you will have to return false as well.
Great.. Thanks a lot Rob and Bear. It works well. I got it now. I have one more question.How to pass dynamic parameters as query strings with a link?
<a href="knv.jsp" onklick="return clicked()" >Known Values</a> I'm selecting a value from a dropdown. I need to pass this dynamic value to another page.
I've just done this in the past (Bear probably has a better way) just build up your URL in the javascript and the use document.location to redirect to the page but doing this just make sure you return false to the href onclick all the time so there aren't 2 redirects atempts happening. Bear might suggest using getElementById and doing something with the URL but I've just used this way.
As Bear suggested, just submit the form. Once back in the JSP you can just build your URL and send a redirect there before touching any subs within the JSP or do the javascript buildup if a different page.