0

This seems like it should be quite easy, but I'm not sure why it isn't working. I have a button I create in Razor like so:

@Html.ActionLink("Next", "Add-Remove", "Catalogue-Item-Authors", new { id = Model.CatalogueItemID }, new { @class = "btn btn-default", @id = "next-button", @disabled="disabled" })

I want it to be disabled as first, but when my submit button is clicked, it should be enabled. I have a form and in the OnSuccess parameter of the form I call EnableNext(). Here is the function:

function EnableNext() {
     document.getElementByID('next-button').disabled = false;
}

It gets called at the right time, I verified that by placing alert("test") in the funciton, but the button is never enabled. Can anyone see why my button wouldn't be getting enabled?? Thanks.

5
  • do you check id attribute generated for your button, it really next-button? also for enabling you can remove attribute disable Commented Mar 3, 2015 at 14:10
  • the ActionLink generated anchor tag, not button. Anchor tag does not have attribute disabled if i'm not mistaken. Commented Mar 3, 2015 at 14:15
  • the id is definitely correct I verified it, if the anchor tab does have a disabled attribute then how do I enable it? It is being disabled fine, I must be able to enable it somehow. Commented Mar 3, 2015 at 14:18
  • Yeah try Tom's answer, I think it should work Commented Mar 3, 2015 at 14:19
  • Problem was the 'D' instead of 'd' stupid mistake, sorry guys thanks for the help! Commented Mar 3, 2015 at 14:20

1 Answer 1

1

I'm not sure why setting disabled = false is not working, perhaps because you are using an anchor tag and not a button tag, but what does work is doing:

document.getElementById('next-button').removeAttribute('disabled')

Also, note that the d in getElementById should not be capitalized.

Sign up to request clarification or add additional context in comments.

1 Comment

The issue was the 'D' instead of 'd'...I knew it had to be something stupid. Thanks a lot!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.