Solved

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

Posted on 2014-09-19
2
234 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Enroll in June's Course of the Month

June’s Course of the Month is now available! Experts Exchange’s Premium Members, Team Accounts, and Qualified Experts have access to a complimentary course each month as part of their membership—an extra way to sharpen your skills and increase training.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Turn A Profile Picture Into A Cartoon Using Photoshop And Illustrator This tutorial will teach you how to make a cartoon style image out of a regular picture. I have tried to keep the tutorial as simple as possible. I used Adobe CS4 for this tuto…
This guide will walk you through the essential considerations and tech stack for building scalable websites. Know how to grow your business the smart way!
The purpose of this video is to demonstrate how to make a WordPress Site faster and smaller in size by cleaning up the database. This will be demonstrated using a Windows 8 PC. Plugin WP Optimize will be used. Go to your WordPress login page. T…
The purpose of this video is to demonstrate how to manually back up a WordPress Database. This will be demonstrated using a Windows 8 PC. The Host used will be IPage.com Log into your Hosting account. IPage will be used for demonstration : Locat…

717 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