Solved

how can I disable button if table row appended was Empty?

Posted on 2014-09-19
2
208 Views
Last Modified: 2014-09-20
I have a create button which disabled at first I want to enable it when the table row has a record, how can i do this? I have jquery here, how can I improved this?

 $("#btnCreateExecutiveShareList").click(function () {
         
            var numberOfRows = $('#AppendedTableEmployeeShare > tbody > tr').length;
            if (numberOfRows == 0 || numberOfRows == "") {
                $("#btnCreateExecutiveShareList").attr("disabled", true)
            }
            else
            {
                $("#btnCreateExecutiveShareList").attr("disabled", false)
            }
        });
0
Comment
Question by:jabz ayuap
2 Comments
 
LVL 21

Accepted Solution

by:
Randy Poole earned 500 total points
ID: 40332333
What you are doing is fine. If you want to compact it then:
 $("#btnCreateExecutiveShareList").click(function () {
          
            var numberOfRows = $('#AppendedTableEmployeeShare > tbody > tr').length;
            $("#btnCreateExecutiveShareList").attr("disabled", (numberOfRows == 0 || numberOfRows == ""));
        });

Open in new window

0
 

Author Comment

by:jabz ayuap
ID: 40332357
Hi randy what if the number of rows = 0 and the button disabled what if i remove the value, how can i disable it again?
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

When deciding to adopt any help desk solutions many factors should be explored before taking decisions. This will change from business to another but in general there are some kind of rule of thumb. Here are some quick tips: Do we need only ticket…
In this short web based tutorial, I wanted to show users how they can still use the powers of FrontPage in conjunction with Expression Web 3.  Even though Microsoft eliminated the use of Web components, we can still use them with FrontPage and edit …
The purpose of this video is to demonstrate how to create a Printer Friendly PDF on a WordPress Page. This will be demonstrated using a Windows 8 PC. Tools Used are Photoshop, Awesome Screenshot” Google Chrome Extension, and SmallPDF.com Log…
The purpose of this video is to demonstrate how to insert an Iframe into WordPress. This will be demonstrated using a Windows 8 PC. Go to your WordPress login page. This will look like the following: mywebsite.com/wp-login.php : Open Page or Post…

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now