Solved

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

Posted on 2014-09-19
2
229 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

Report: Liquid Web beats Amazon, Rackspace & More

A study by performance analyst firm Cloud Spectator finds that Liquid Web beats rivals Amazon, Rackspace and DigitalOcean when it comes to website and cloud application performance.

Question has a verified solution.

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

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 …
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 properly insert a Vimeo Video into a WordPress site or Blog. This will be demonstrated using a Windows 8 PC. Go to your WordPress login page. This will look like the following: mywebsite.com/wp…
The purpose of this video is to demonstrate how to set up an RSS Feed on a WordPress Website. This will be demonstrated using a Windows 8 PC. Feedburner will be used for this demonstration. Go to your WordPress login page. This will look like the…

739 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