File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes HTML, CSS and JavaScript and the fly likes Please help me to enable and disable anchor tag Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Please help me to enable and disable anchor tag " Watch "Please help me to enable and disable anchor tag " New topic
Author

Please help me to enable and disable anchor tag

praveen michael
Greenhorn

Joined: May 15, 2009
Posts: 2
I have a problem in disabling anchor tag.

Let me tell the scenario...

I have a page that contains a checkbox and two button images inside two anchor tags.

<table>
<tr>
<td><input type="checkbox" id="chk1">I Agree</td>
</tr>
</table>

<div>
<a ><img />Submit</a>
<a ><img />Reset</a>
</div>

- This submit button should be disabled by default.
when clicks on checkbox it should enable.

- When click on the reset it has to uncheck the check box and disable the submit button.
- Please make this code for IE and firefox
Can you please anyone help me?
Balu Sadhasivam
Ranch Hand

Joined: Jan 01, 2009
Posts: 874

The most easy way would be , but not sure if this is efficient way
[code]

function call() { // call this function from checkbox
var a= document.getElementById("a1");
a.href="/link2";
}

<a id="a1" >Submit</a>
<a id="a2" >Reset</a>

[/code]
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10535
    
    9

Have you considered dropping the anchor? Around 200 fathoms of chain should do.


[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
praveen michael
Greenhorn

Joined: May 15, 2009
Posts: 2
Can you please elaborate the code??

I have to set the submit anchor tag disabled true first.
Balu Sadhasivam
Ranch Hand

Joined: Jan 01, 2009
Posts: 874


Do not set the href for anchor tag. It would look like disabled.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61761
    
  67

Please take the time to choose the correct forum for your posts. This forum is for meaningless drivel posts. For more information, please read this.

This post has been moved to a more appropriate forum.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61761
    
  67

Balu Sadhasivam wrote:Do not set the href for anchor tag. It would look like disabled.
Not so. It will simple appear as normal text in most browsers.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61761
    
  67

<a ><img />Submit</a>

What is up with this construct? is this really the way you have your HTML arranged? Really? If so, why?

Why aren't you using a real button element?
Balu Sadhasivam
Ranch Hand

Joined: Jan 01, 2009
Posts: 874

Bear Bibeault wrote:
Balu Sadhasivam wrote:Do not set the href for anchor tag. It would look like disabled.
Not so. It will simple appear as normal text in most browsers.


yeah i meant that
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Please help me to enable and disable anchor tag