Hello all!
I have two asp buttons that are in the header and footer of an asp DataList, and I am trying to use javascript to disable them based off a bool variable that is set in the codebehind. Because these buttons are in the datalist I thought it would be easier to use class names to find them. I have had no luck in getting the buttons disabled though. The following is what I have come up with and attempted.
In the browser I am able to see that the bool variable isQtyValid is there. Is my problem with trying to getElementsByClassName? I did a check to see the length of what bb is and it returns 2 like I thought it would. Or is my problem that bb is a generic object and needs to be cast as a button?
I am no pro when it comes to javascript, that is a for sure haha, but I know some basics, and with the help of google I am usually able to piece together something that works, but this time I have not been able to find much resources pertaining to my particular situation.
Thanks for your time! Any tips or pointers are appreciated! If you think you need more info just let me know and I will do my best to get it to you.
I have two asp buttons that are in the header and footer of an asp DataList, and I am trying to use javascript to disable them based off a bool variable that is set in the codebehind. Because these buttons are in the datalist I thought it would be easier to use class names to find them. I have had no luck in getting the buttons disabled though. The following is what I have come up with and attempted.
function SetButtonStatus() { var bb = document.getElementsByClassName('Buttonsubmit'); for (var i = 0; i < bb.length; i++) { bb.disabled = "<%=!isQtyValid%>"; } }
In the browser I am able to see that the bool variable isQtyValid is there. Is my problem with trying to getElementsByClassName? I did a check to see the length of what bb is and it returns 2 like I thought it would. Or is my problem that bb is a generic object and needs to be cast as a button?
I am no pro when it comes to javascript, that is a for sure haha, but I know some basics, and with the help of google I am usually able to piece together something that works, but this time I have not been able to find much resources pertaining to my particular situation.
Thanks for your time! Any tips or pointers are appreciated! If you think you need more info just let me know and I will do my best to get it to you.