Question: I have a table in that I have 2 fields: `Logid` and `Type`:

```
 +---------+---------+
 |  Logid  |  Type   |
 +---------+---------+
 |    1    |  PHP    |
 |    2    |  Mysql  |
 |    3    |  PHP    |
 |    4    |  JAVA   | 
 |    5    |  PHP    | 
 |    6    |  MYSQL  |
 +---------+---------+

```

I need to get all `Logid` by `logs_operationtype` group,  

I need to get the output as:

```
 +------------+---------+
 |  Logid     |  Type   |
 +------------+---------+
 |    1,3,5   |  PHP    |
 |    2,6     |  Mysql  |
 |    4       |  JAVA   |
 +------------+---------+

```

Answer: 
You will need to change this portion of your code - 

```
// Check to see if there is 250 in the url
var bal_amount = document.getElementById('balance_amount');
if (bal_amount.value > 0)
{
    $("#a").show();
}

```

You are executing the above piece of code inside `document ready` event, which means it will be executed right when the page loads, and only once.

To remedy this, you need to place this code inside an event handler - 

```
​$(document).ready(function () {
    $("#a").hide();

    // See this? This is the event handler for the
    // change event which will fire whenever the value
    // of the text box changes.
    $('#balance_amount').change(function () {
        // Check to see if there is 250 in the url
        if ($(this).val() > 0) {
            $("#a").show();
        }
    });
});​

```

In this way, whenever the value of the `balance_amount` field changes, this event will trigger and validate your balance amount for your.

[Here](http://jsfiddle.net/f5Ppa/) you will find a working demo.

You can further improve your code by checking for invalid input in the text box - 

```
​$(document).ready(function () {
    $("#a").hide();

    // See this? This is the event handler for the
    // change event which will fire whenever the value
    // of the text box changes.
    $('#balance_amount').change(function () {

        var balance = parseInt($(this).val(), 10);
        if (isNaN(balance)) {
            alert('You have entered an invalid value');
            return false;
        }

        if (balance > 0){
            $("#a").show();
        }

        // There you go, an else block for you
        else {
            $("#a").hide();
        }
    });
});​

```
Try this:

```
$(document).ready(function(){
        $("#a").hide();
   $('#balance_amount').keyup(function () {
        // Check to see if there is 250 in the url
        var bal_amount = $('#balance_amount').val();
        if (bal_amount.value > 0) {
            $("#a").show();
        }
    }
});

```