jeudi 30 avril 2015

Receive value from checkbox JAVA

I have 2 checkbox Male and Female. I want when I click to Male checkbox and press button Add, the row of Table will get value "Male", I use addItemListener to checkbox but I have to press 2 times then the value appear. So can anyone know how to do that easier. Thank you !

public void Add () throws SQLException
{   

    String MNV = TX1.getText();
    String HNV = TX2.getText();
    String TNV = TX3.getText();
    String GT1 = Nam.getText();
    String GT2 = Nu.getText();
    String NS = TX5.getText();
    String TD = TX6.getText();
    String SDT = TX7.getText();
    String DC = TX8.getText();
    Statement s = connect.createStatement();
    Nam.addItemListener(new ItemListener()
    {
        public void itemStateChanged (ItemEvent E)
        {          
            try {                    
                s.execute("INSERT INTO `nhanvien` "
                        + "(`MÃ NV`, `HỌ NV`, `TÊN NV`, `GIỚI TÍNH`, `NĂM SINH`, `TRÌNH ĐỘ`, `SỐ ĐT`, `ĐỊA CHỈ`)"      
                        + " VALUES ('"+MNV+"', '"+HNV+"', '"+TNV+"',   '"+GT1+"', '"+NS+"', '"+TD+"', '"+SDT+"', '"+DC+"');");
                GetData();
            } catch (SQLException ex) {
                Logger.getLogger(NewClass.class.getName()).log(Level.SEVERE, null, ex);
            }

        }
    });




Unable to count checked checkboxes from another page with jquery

I have multiple set of checkboxes. I want to count a particular set of checkboxes.These checkboxes given the class 'sub'. The interesting part is, they are fetched by an akax call from another php page. So the counter isn't working.

<script>
$("[id^=sub][type=checkbox]").change(function () {
    $('#count').text($("[id^=sub][type=checkbox]").length);
});
</script>

When I use below script, the checkboxes which is in the html page itself, it counts the very first set of the checkboxes! These are the checkboxes clicked to fetch those sub checkboxes!

Now how do I count that particular checkboxes of 'sub' class which are fetched by ajax call please?

<script>
$("input:checkbox").change(function () {
    $('#count').text($("input:checkbox:checked").length);
});

</script>

This is the fetched checkboxes structure.

<input type="checkbox" class="sub" name="sub['.$subjects_id.']" id="sub" value="">

ANd I display the count in the html page like this:

<p id="count"></p>




JQuery not selecting all in from checkbox

I cannot seem to get my JQuery working. I have attached my view which has a loop that shows every model in a table format. Each model has a checkbox beside it. The table head also has a checkbox item name/id as checkAll. I have referenced my JQuery script and added my function. I cannot get the function to work, when I click on the checkAll check box nothing happens. I'm extremely new to JQuery and cannot work this one out?

@model IEnumerable<MVC_Example2___ADO.Models.Employees>

@{
    ViewBag.Title = "Delete";
}
<script src="http://ift.tt/yyiuBY" type="text/javascript" >
</script>
<script type="text/javascript">
    $(function () {
        $("#checkAll").click(function () {
            $("input[name='EmployeeIDToDelete']").click(function () {
                if ($("input[name='EmployeeIDToDelete']").length == $("input[name='EmployeeIDToDelete']:checked").length) {
                    $("#checkAll").attr("checked", "checked");
                }
                else {
                    $("#checkAll").removeAttr("checked");
                }
            })
        })
    })
</script>
<html>
<body>
    @using (Html.BeginForm())
    {
        <table align="center" border="1" style="border:ridge;">
            <thead>
                <tr>
                    <td><input type="checkbox" id="checkAll" name="checkAll" /> </td>
                    <td>Photo</td>
                    <td>Name</td>
                    <td>Gender</td>
                </tr>
            </thead>
            <tbody>
                @Html.EditorForModel()
            </tbody>
        </table>
        <input type="submit" name="submit" value="Delete Entries" />
    }
</body>
</html>




Javascript issues - filter in Google Fusion Tables using checkboxes

I'm trying to add a simple set of checkboxes to my google fusion tables map in order to use as turning on and off layers much like this example: http://ift.tt/1Jcozib (but without the expanding sidebar). This project does exactly what I want it do, but making my code very similar to his still does not work.

Basically, my checkboxes aren't doing anything. Here's a link to my project: http://ift.tt/1Jcqrr8

Is there something I'm not doing correctly with my javascript? I'm pretty new to it. Thank you!

And here's my code:

var map;
var layer_0;
var tableId;
var layer;
function initialize() {
  map = new google.maps.Map(document.getElementById('map-canvas'), {
    center: new google.maps.LatLng(30.27439220767769, -97.71868322157854),
    zoom: 12,
    mapTypeId: google.maps.MapTypeId.ROADMAP
  });
  layer_0 = new google.maps.FusionTablesLayer({
    query: {
      select: "col11",
      from: "19xTr3sBmz3hB9n-L14no0BWZgbFJcAGdJNoOoTit"
    },
    map: map,
    styleId: 2,
    templateId: 3
  });
  tableId = "19xTr3sBmz3hB9n-L14no0BWZgbFJcAGdJNoOoTit"
  ;
  layer = new google.maps.FusionTablesLayer();
    filterMap(layer, tableId, map);

    google.maps.event.addDomListener(document.getElementById('signals'),
        'click', function() {
          filterMap(layer, tableId, map);
    });

    google.maps.event.addDomListener(document.getElementById('wavetronix'),
        'click', function() {
          filterMap(layer, tableId, map);
    });

    google.maps.event.addDomListener(document.getElementById('bluetooth'),
        'click', function() {
          filterMap(layer, tableId, map);
    });
}

function filterMap(layer, tableId, map) {
    var where = generateWhere();

    if (where) {
      if (!layer.getMap()) {
        layer.setMap(map);
      }
      layer.setOptions({
        query: {
          select: 'col14',
          from: tableId,
          where: where
        }
      });
    } else {
      layer.setMap(null);
    }
}
function generateWhere() {
  var filter = [];
  var stores = document.getElementsByName('store');
  for (var i = 0, store; store = stores[i]; i++) {
    if (store.checked) {
      var storeName = store.value.replace(/'/g, '\\\'');
      filter.push("'" + storeName + "'");
    }
  }
  var where = '';
  if (filter.length) {
    where = "'col14' IN (" + filter.join(',') + ')';
  }
return where;
} 
//end new stuff 
function changeMap_0() {
  var whereClause;
  var searchString = document.getElementById('search-string_0').value.replace(/'/g, "\\'");
  if (searchString != '--Select--') {
    whereClause = "'Location' = '" + searchString + "'";
  }
  layer_0.setOptions({
    query: {
      select: "col11",
      from: "19xTr3sBmz3hB9n-L14no0BWZgbFJcAGdJNoOoTit",
      where: whereClause
    }
  });
}
function changeMap_1() {
  var whereClause2;
  var searchString = document.getElementById('search-string_1').value.replace(/'/g, "\\'");
  if (searchString != '--Select--') {
    whereClause2 = "'Street_1 Street_2' CONTAINS IGNORING CASE '" + searchString + "'";
  }
  layer_0.setOptions({
    query: {
      select: "col11",
      from: "19xTr3sBmz3hB9n-L14no0BWZgbFJcAGdJNoOoTit",
      where: whereClause2
    }
  });
}
function changeMap_2() {
  var whereClause2;
  var searchString = document.getElementById('search-string_2').value.replace(/'/g, "\\'");
  if (searchString != '--Select--') {
    whereClause2 = "'Jurisdictn' CONTAINS IGNORING CASE '" + searchString + "'";
  }
  layer_0.setOptions({
    query: {
      select: "col11",
      from: "19xTr3sBmz3hB9n-L14no0BWZgbFJcAGdJNoOoTit",
      where: whereClause2
    }
  });
}
function changeMap_3() {
  var whereClause3;
  var searchString = document.getElementById('search-string_3').value.replace(/'/g, "\\'");
  if (searchString != '--Select--') {
    whereClause2 = "'County' = '" + searchString + "'";
  }
  layer_0.setOptions({
    query: {
      select: "col11",
      from: "19xTr3sBmz3hB9n-L14no0BWZgbFJcAGdJNoOoTit",
      where: whereClause2
    }
  });
}
function Reset() {
  var whereClause3;
  var searchString = document.getElementById('search-string_1').value.replace(/'/g, "\\'");
  if (searchString != '--Select--') {
    whereClause2 = "'Street_1' CONTAINS IGNORING CASE '" + searchString + "'";
  }
  layer_0.setOptions({
    query: {
      select: "col11",
      from: "19xTr3sBmz3hB9n-L14no0BWZgbFJcAGdJNoOoTit",
      where: whereClause3
    }
  });
}
function Clear() {
document.getElementById("search-string_1").value= "";
}
google.maps.event.addDomListener(window, 'load', initialize);


  <center><label class="layer-wizard-search-label">
    County</label>
    <select id="search-string_3" onchange="changeMap_3(this.value);">
      <option value="--Select--">--Select--</option>
      <option value="Bastrop">Bastrop</option>
      <option value="Burnet">Burnet</option>
      <option value="Caldwell">Caldwell</option>
      <option value="Hays">Hays</option>
      <option value="Travis">Travis</option>
      <option value="Williamson">Williamson</option>
    </select><label class="layer-wizard-search-label">
    City</label>
    <select id="search-string_0" onchange="changeMap_0(this.value);">
      <option value="--Select--">--Select--</option>
      <option value="Austin">Austin</option>
      <option value="Bastrop">Bastrop</option>
      <option value="Bee Cave">Bee Cave</option>
      <option value="Bertram">Bertram</option>
      <option value="Buda">Buda</option>
      <option value="Burnet">Burnet</option>
      <option value="Caldwell CO">Caldwell CO</option>
      <option value="Cedar Creek">Cedar Creek</option>
      <option value="Cedar Park">Cedar Park</option>
      <option value="Creedmoor">Creedmoor</option>
      <option value="Dripping Springs">Dripping Springs</option>
      <option value="Elgin">Elgin</option>
      <option value="Florence">Florence</option>
      <option value="Georgetown">Georgetown</option>
      <option value="Granite Shoals">Granite Shoals</option>
      <option value="Hutto">Hutto</option>
      <option value="Kingsland">Kingsland</option>
      <option value="Kyle">Kyle</option>
      <option value="Lago Vista">Lago Vista</option>
      <option value="Lakeway">Lakeway</option>
      <option value="Leander">Leander</option>
      <option value="Liberty Hill">Liberty Hill</option>
      <option value="Lockhart">Lockhart</option>
      <option value="Luling">Luling</option>
      <option value="Manor">Manor</option>
      <option value="Marble Falls">Marble Falls</option>
      <option value="Martindale">Martindale</option>
      <option value="Maxwell">Maxwell</option>
      <option value="Pflugerville">Pflugerville</option>
      <option value="Rollingwood">Rollingwood</option>
      <option value="Round Rock">Round Rock</option>
      <option value="San Marcos">San Marcos</option>
      <option value="Serene Hills">Serene Hills</option>
      <option value="Smithville">Smithville</option>
      <option value="Spicewood">Spicewood</option>
      <option value="Sunset Valley">Sunset Valley</option>
      <option value="Taylor">Taylor</option>
      <option value="Travis CO">Travis CO</option>
      <option value="Williamson CO">Williamson CO</option>
      <option value="West Lake Hills">West Lake Hills</option>
      <option value="Wimberley">Wimberley</option>
      <option value="Woodcreek">Woodcreek</option>
      <option value="Wyldwood">Wyldwood</option>
    </select> 
    <label class="layer-wizard-search-label">
      Jurisdiction</label>
    <select id="search-string_2" onchange="changeMap_2(this.value);">
      <option value="--Select--">--Select--</option>
      <option value="City of Austin">Austin</option>
      <option value="City of Cedar Park">Cedar Park</option>
      <option value="City of Georgetown">Georgetown</option>
      <option value="City of Leander">Leander</option>
      <option value="City of Round Rock">Round Rock</option>
      <option value="City of Taylor">Taylor</option>
      <option value="TxDOT">TxDOT</option>
      <option value="Williamson County">Williamson County</option>
    </select> 
  <label class="layer-wizard-search-label">
      Street</label>
    <input onkeydown="if (event.keyCode == 13) document.getElementById('changeMap_1').click()" type="text" id="search-string_1">
    <input type="button" onclick="changeMap_1()" id="changeMap_1" value="Search">
    <input type="button" onclick="Reset(); Clear();" value="Reset"><br>
    <input type="checkbox" name="store" checked="checked"
        id="signals" value="Signals">
        <label>Signals</label>
    <input type="checkbox" name="store"
        id="bluetooth" value="Wavetronix">
        <label>WaveTronix Readers</label>
    <input type="checkbox" name="store"
        id="bluetooth" value="Bluetooth">
        <label>Bluetooth Readers</label></center>
</div>




How to create checkbox in iOS?

I have taken two custom buttons and one method, to set their check and uncheck

In viewdidload() i have written like this..

[checkbox_01 setImage:[UIImage imageNamed:@"unchecked.png"] forState:UIControlStateNormal];
[checkbox_02 setImage:[UIImage imageNamed:@"unchecked.png"] forState:UIControlStateNormal];
isChecked_01 = NO; //declared as boolean to change check and uncheck for button one
isChecked_02 = NO; //declared as boolean to change check and uncheck for button two

And in method

-(IBAction)checkboxOnClick:(UIButton *)sender {
    if (sender.tag == 1) {
        if (isChecked_01 == NO) {
            [checkbox_01 setImage:[UIImage imageNamed:@"checked.png"] forState:UIControlStateNormal];
            isChecked_01 = YES;
        }
        else
        {
            [checkbox_01 setImage:[UIImage imageNamed:@"unchecked.png"] forState:UIControlStateNormal];
            isChecked_01 = NO;
        }
    }

    if (sender.tag == 2) {
        if (isChecked_02 == NO) {
            [checkbox_02 setImage:[UIImage imageNamed:@"checked.png"] forState:UIControlStateNormal];
            isChecked_02 = YES;
        }
        else
        {
            [checkbox_02 setImage:[UIImage imageNamed:@"unchecked.png"] forState:UIControlStateNormal];
            isChecked_02 = NO;
        }
    }
}

is there any other way to create check boxes in ios..? i have taken each checkbox with one isChecked boolean value for it.. is there posibilities to use only one boolean for entire check list.....




Adding Multiple Checkbox values to a Label C#

Im currently trying to do my school practical assignment but im facing some issues. Basically what i want to do is to add up the values of the multiple checkboxes. Im doing a food menu.

Here is my code.

//Ingredients Price ONLY

double vegetable = 0.60;
double fishball = 0.90;
double tofu = 0.80;
double mushroom = 1.20;

i dont know what is the next step.

I just started learning visual studio so its best if everything is kept simple. Thanks in advance!




Filter table with checkboxes

I am filtering a table with checkboxes. The code I have works fine, in some aspects.

I want it to filter results if they meet all the checks, not one.

based on: How can I add to my table filter to allow for multiple checkbox selections, as well as filtering from a dropdown?

My Example

$("input[name='filterStatus'], select.filter").change(function() {
  var classes = [];
  var stateClass = ""

  $("input[name='filterStatus']").each(function() {
    if ($(this).is(":checked")) {
      classes.push('.' + $(this).val());
    }
  });

  if (classes == "" && stateClass == "") {
    // if no filters selected, show all items
    $("#StatusTable tbody tr").show();
  } else {
    // otherwise, hide everything...
    $("#StatusTable tbody tr").hide();

    // then show only the matching items
    rows = $("#StatusTable tr" + stateClass).filter(classes.length ? classes.join(',') : '*');
    if (rows.size() > 0) {
      rows.show();
    }
  }

});
<html>

<head>
  <script src="http://ift.tt/1g1yFpr"></script>
</head>

<body>
  <form name="FilterForm" id="FilterForm" action="" method="">
    <input type="checkbox" name="filterStatus" value="ISO " />
    <label for="filter_1">ISO</label>
    <input type="checkbox" name="filterStatus" value="AMCA" />
    <label for="filter_2">AMCA</label>
    <input type="checkbox" name="filterStatus" value="UL" />
    <label for="filter_3">UL</label>
  </form>

  <table border="1" id="StatusTable">
    <thead>
      <tr>
        <th>Name</th>
        <th>ISO</th>
        <th>AMCA</th>
        <th>UL</th>
      </tr>
      <tbody>
        <tr class="ISO">
          <td class="Name">Name1</td>
          <td class="ISO">&#x2713;</td>
          <td class="AMCA">&nbsp;</td>
          <td class="UL">&nbsp;</td>
        </tr>
        <tr class="ISO AMCA">
          <td class="Name">Name2</td>
          <td class="ISO">&#x2713;</td>
          <td class="AMCA">&#x2713;</td>
          <td class="UL">&nbsp;</td>
        </tr>
        <tr class="ISO AMCA UL">
          <td class="Name">Name3</td>
          <td class="ISO">&#x2713;</td>
          <td class="AMCA">&#x2713;</td>
          <td class="UL">&#x2713;</td>
        </tr>

      </tbody>
  </table>
  <script></script>
</body>

</html>

Thanks for your concern




How to size input[type=checkbox] elements using css

We have been sizing checkboxes using transform:scale(1.5) for sometime. Recently something has changed in the browsers, because it is no longer working. For example on Chrome Version 42.0.2311.135 (64-bit) updated today (4/30/15), the following code doesn't work. The size jumps to about 3X. Changing the scale number (for example to 1.1) has no effect.

<html>
<head></head>
<body>
    <input type="checkbox" style="-webkit-transform:scale(1.5)">
</body>
</html>

So, does anyone know how to size a checkbox using current browsers? I've tried all the solutions I have read about (font-size:x-large, setting height, width, font-size, ...)




Coldfusion Search Results Filter with checkboxes and Jquery

I am developing a website for employment. On the search results page i pass the url variables to a Coldfusion component which returns the results in JSON format and then gets outputted with a handlebars template (thanks to a script by Raymond Camden which can be found here).

I would like to filter the results using checkboxes based on the various categories from my db, there is a PHP tutorial online which does exactly what i would like my search page to do and that can be found here

Here is my is script and the handlebars template:

handlebars template:

 <script id="results-template" type="text/x-handlebars-template">
    {{#each records}}

        <div class="search-results">
             <h3 class="text-left">{{job_title}}</h3>
            <ul class="list-group">
                <li class="list-group-item">DATE POSTED: {{job_date_post}}</li>
                <li class="list-group-item">JOB REF NO: {{job_ref_no}}</li>
                <li class="list-group-item">INDUSTRY: {{job_industry}}</li>
                <li class="list-group-item">KEYWORDS: {{job_keywords}}</li>
                <li class="list-group-item">JOB TYPE: {{job_type_id}}</li>
            </ul>
        </div>


    {{/each}}
</script>

Here is the ajax call:

 <script>
 function cfQueryNormalize(d) {
    var result = [];
    for(var i=0, len=d.DATA.length; i<len;i++) {
        var item = {};
        for(var k=0,innerlen=d.COLUMNS.length; k<innerlen; k++ ) {
            item[d.COLUMNS[k].toLowerCase()] = d.DATA[i][k];
        }
        result.push(item);
    }
    return result;
} 


$(document).ready(function() {

    //Get the contents from the script block 
    var source = document.querySelector("#results-template").innerHTML;
    //Compile that baby into a template
    template = Handlebars.compile(source);



    $.get("cfc/search-results.cfc?method=getresults&returnformat=json", {city:"<cfoutput>#url.city#</cfoutput>", Keywords:"<cfoutput>#url.keywords#</cfoutput>"}, function(res,code) {
        var d = cfQueryNormalize(res);
        var html = template({records:d});
        $("#results").html(html);
    }, "json");

    });

</script>

Here is the Coldfusion Component:

 <cffunction access="remote" name="getresults" output="false" >

 <cfargument name="city" displayName="city" type="string" hint="Displays the Search Results"  />
 <cfargument name="keywords" displayName="keywords" type="string" hint="Displays the Search Results"  />
 <cfargument name="salary_id" displayName="salary_id" type="string" hint="Displays the Salary Results" />
 <cfargument name="job_type_id" displayname="job_type_id" type="string" required="no">
 <cfargument name="job_industry" displayname="job_industry" type="string" required="no">

 <cfquery name="getresults" datasource="#datasource#" username="#username#" password="#password#">
  SELECT jobs.job_id, 
    jobs.job_title, 
    jobs.job_type_id,
    jobs.job_salary_id, 
    jobs.job_salary, 
    jobs.loc_country, 
    jobs.loc_region, 
    jobs.loc_city, 
    jobs.job_date_post, 
    jobs.job_ref_no, 
    jobs.job_detail_organization, 
    jobs.job_detail_requirements, 
    jobs.job_detail_description, 
    jobs.recruiter_id, 
    jobs.job_industry, 
    jobs.job_sub_industry, 
    jobs.job_keywords, 
    jobs.job_active, 
    jobs.job_applications, 
    jobs.job_views
 FROM jobs
 WHERE <cfif #Arguments.city# GT''>jobs.loc_city = #Arguments.city# AND</cfif> jobs.job_keywords LIKE '%#Arguments.keywords#%' <cfif Isdefined ('Arguments.salary_id')>AND jobs.job_salary_id = #Arguments.salary_id#</cfif>
 </cfquery>

 <cfreturn getresults> 
 </cffunction>

My checkboxes will be based on :

1) Salary and they will have a range of yearly salary amounts

2) Job Type - Permanent, Part Time, Tempory etc

3) Job Industry.

The results all have the corresponding checkbox fields in the db.

How would i be able to click on one or more of the checkboxes and refine the results in the Coldfusion component based on the selection i have made?

Any help would be greatly appreciated.




Checkbox is not checking

I have a method that gets called when a button (checkbox) is clicked that should change the background image of the button. I have an NSLog that tells me that the method was called but the image never changes. I can't figure out why.

Thanks for the help!

let checkedImage = UIImage(named: "checkedBox")
let uncheckedImage = UIImage(named: "uncheckedBox")

func checkboxClicked(sender: UIButton!) {
    if sender == self {
        if isChecked == true {
            NSLog("Change background image")
            sender.setBackgroundImage(checkedImage, forState: .Normal)
            isChecked == false
        } else {
            NSLog("Change background image")
            sender.setBackgroundImage(uncheckedImage, forState: .Normal)
            isChecked == true
        }
    }
}




Select all the checkboxes inside the same loop iteration using AngularJS

What I'm trying to achieve is to check some checkboxes belonging to a ng-repeat loop iteration when I check a "master" checkbox. My code so far in the view:

<div ng-app="CheckAllModule">
    <div ng-controller="checkboxController">
        <ul ng-repeat="s in struct">
            <li><strong>{{s}} item</strong>
                <input type="checkbox" ng-checked="x1 && x2 && x3" ng-model="selectedAll" ng-click="checkAll()" />
            </li>
            <label>Subitem A
                <input type="checkbox" ng-checked="chk" ng-model="x1" />
            </label>
            <label>Subitem B
                <input type="checkbox" ng-checked="chk" ng-model="x2" />
            </label>
            <label>Subitem C
                <input type="checkbox" ng-checked="chk" ng-model="x3" />
            </label>
        </ul>
    </div>
</div>

Where the first checkbox is the "master" and should impose its own state to the "slaves" (the next three checkboxes), no matter what was their previous state.

Regarding to the slave checkboxes, they should be checked & unchecked indepently. But If the three are checked at the same time, the master should be too. Whenever only one of them is not checked, the master shouldn't be as well.

And my controller:

var app = angular.module("CheckAllModule", []);
app.controller("checkboxController", function ($scope) {
    $scope.struct = ['First', 'Second'];
    $scope.checkAll = function () {
        if ($scope.selectedAll) {
            $scope.chk = true;
        } else {
            $scope.chk = false;
        }
    };
});

Any help? Thx!




Kendo Listview, added checkboxes, added a select all, will check and uncheck all once, will not check all again.

I would like some help with this. I have a Kendo Listview:

 <form id="frmChk">
        @(Html.Kendo().ListView<thieme_ws3.Models.QaTestModel>(Model)
        .Name("testList")
        .TagName("fieldset")
        .HtmlAttributes(new { @class = "panel panel-primary panel-body" })
        .ClientTemplateId("template")
        )
        <br />
    </form>

Where I have added checkboxes to the information brought in:

<script type="text/x-kendo-tmpl" id="template">
        <div class="col-md-5">
        @Html.CheckBox("cb_#:Id#", new { @class = ".item", id = "cb_#:Id#" })  #=Name#
        </div>
    </script>

I have added a select all checkbox:

 <label id="checkAll" class="checkbox">
        <input type="checkbox" id="all" name="all" /> Select all
    </label>

And added this to fire it:

 $('#all').on('click', function (e) {
    //alert("I'm clicked!" + this.checked);
    var testList = $("#testList").data("kendoListView");
    var dataItems = testList.dataItems();

    //do thought to wrap the loop in a do while, caused the browser to stop
    {

        for (i = 0; i <= dataItems.length - 1; i++) {
            //alert(dataItems[i].id);
            var cb = $("#cb_" + dataItems[i].Id);
            if (this.checked) {
                cb.attr("checked", "checked");
            }
            else {

                (cb.removeAttr("checked"));
            }

        }
    }
    })

It will work once, checking all boxes and unchecking all boxes but when I check the select all again, it will not select the others. I am certain it is something small I am overlooking, please help.




Issue with checkbox on zend framework 1

I have an issue with a checkbox: it does not update to the database.

$emailnotification = new Zend_Form_Element_Checkbox('emailnotification ', 'emailnotification', array(
    'checkedValue'  => 1,
    'uncheckedValue' => 0,
) );
$emailnotification->setLabel('emailnotification');
$emailnotification->setValue(1);
$this->addElement($emailnotification);

and on Controller i have action update the following code below for update :

if($this->_request->isPost())
    {
        $formData = $this->getRequest()->getPost();
        if($form->isValid($formData))
        {
            $contact = new Admin_Model_DbTable_Contact();
            $data = array();
           $data['idContact']               = $idContact;
            $data['firstname']              = $form->getValue('firstname');
            $data['lastname']               = $form->getValue('lastname');
                        $data['emailnotification']      = $form->getValue('emailnotification');



            if($contact->editContact($data))
            {

                echo json_encode(array(
                        "response"  =>  true,
                        "message"   =>  "Contact " . $data['firstname'] . " " . $data['lastname'] . "a été modifié"
                ));
                exit();
            }else{
                echo json_encode(array(
                        "response" => false,
                        "errorMessage" => "Il y a eu une erreur dans l'edition de Contact."
                ));
                exit();

Thanks in advance




How to use a checkbox to change values in an SQL database in asp.net

I currently have system which has a web front end and a back office system. User can book properties online or call our office to book a property. In the admin system on the web front, I have two check boxes to determine if the property is available on the front end or the back office system. This is controlled using a Check box. The code for the check box is as follows;

<asp:CheckBox ID="CheckBoxAvailableToWeb" runat="server" TextAlign="Left" Text="Available for web bookings"
                                    Checked="true" />

I have an field in an SQL Database called "isAvailableToWeb" which has a Boolean result. What I want to achieve is if the check box is checked, the value of the "isAvailableToWeb" field is set to "True" or set to "False" if un-checked.

I have tried to complete this function using the following code;

Protected Sub CheckBoxAvailableToWeb_CheckedChanged(sender As Object, e As EventArgs, ByVal beachhutid As Long)
    Using dbContext = New bbhasDBEntities
        Dim AvailableToWeb
        AvailableToWeb = (From i In dbContext.tblBeachHuts Where i.beachHutId = beachhutid Select i.isAvailableToWeb)
        If CheckBoxAvailableToWeb.Checked = True Then
            AvailableToWeb = True
        Else
            AvailableToWeb = False
        End If
    End Using
End Sub

This code doesn't throw up any errors but doesn't also make the change that I would like to see.

I have a button on this page that saves the information so I would also like to know if it would be better, once the code is working, to put it in that Sub.

Any help would be much appreciated.

Thank you.




Keep context menu open after user clicks checkbox?

I have also asked this question here at the chromium Google group.

I would like to be able to keep a context menu open even after a user checks, or unchecks, a checkbox. My plugin allows users to check which devices they are using when testing and when testing multiple devices, it is frustrating to open the context menu several times to tick each device.

Does anyone know of a way to do this? It does not seem to be supported natively. I don't really want to use some magic to re-open the menu, if possible, after a user checks a given device, hence the question here. If it is the best (yet hacky) way, then fair enough. I hope it's not! I menu flickering would also look bad.




How can i make my JavaScript recognise multiple choices from check boxes

For an assignment I am matching user preferences to mobile phone contracts and outputting the matches.

In regards to the network of the contract i want the user to be able to select as many different networks as they like and the program will output any contracts from those network providers. I have it working so it will output a match if only one check box is checked but i am unsure how to modify it so that it will interpret multiple choices and output any contracts with those choices. This is my code so far:

   //Check Network
var userNetwork ="";
var networkForm=document.getElementById("userNetwork");
if(networkForm.NN.checked){
    userNetwork="NN";
}
if(networkForm.Othree.checked){
    userNetwork="03";
}
if(networkForm.Fodavone.checked){
    userNetwork="Fodavone";
}
if(networkForm.ZMobile.checked){
    userNetwork="Z-Mobile";
}


for (var c = 0; c < cont.length; c++) {
    if (userNetwork === cont[c].network || userNetwork === "") {




How to Enable AutoPostBack property and CheckChanged Event to an input[type=checkbox]?

I have an input[type="checkbox"] which have applied it runat="server" to access its value from code-behind. I want to make it raise postback on every checkchanged event but I can't find a property proper for that.

The reason I want to use it instead of a asp:checkbox control is because of its CSS which I found it hard to emulate its style for asp:checkbox control. This is the source of control:

<label class="switch switch-green">
               <input type="checkbox" class="switch-input" id="cbAvailabilityFlag" runat="server" >
               <span class="switch-label" data-on="Yes" data-off="No"></span><span class="switch-handle"></span>    
    </label>




Remove "check" after submit

I've a "stupid" problem: when I click a specific button, I want to reset the checkbox checked in unchecked.

HTML

<input type="checkbox">1
<input type="checkbox">2
<button id="clear">Clear</button>

JS

jQuery("#resetta").click(function(){
jQuery('input:checked').removeAttr('checked');
});




Save Google Form via Android App

I Created an Android app where users can save date to Google Spreedsheet using Google Form. I followed this POST. which I found is very useful for me. But I'm having on trouble, I'm not able to save data of RadioButton , CheckBox, Date....Can anyone please tell me, how to make it possible??




Run query for each checkboxes which are checked

Currently having a page where the admin can assign Contract from one worker to another worker.

My form (working)

<form id='form' name='form' method='POST' action='' style="width:80%!important;">
        <label for='ra'>From :</label>
        <SELECT name='ra' id='ra'>
            <OPTION value=''>
            <OPTION value={$res['idUtilisateur']}> {$res['USR_Login']}  //added with statement
        </SELECT>
        <br/><br/>
        <div id='devis'></div>
        <label for='toRA'>To :</label>
        <SELECT name='toRA' id='toRA'>
            <OPTION value=''>
            <OPTION value={$res['idUtilisateur']}> {$res['USR_Login']} //added with statement
        </SELECT>
    <input type='submit' name='submit' id='submit' value='Change'>
</form>

OPTION are added with sql statement, but I didn't display it.

When I select someone from my SELECT 'ra' (FROM), it displays all of his contracts in a table which checkboxes at each row which has the idContract for value and id.

My question is : How to manage my script.php to transfer every Contracts checked ?

My query would be :

UPDATE Contract
SET idUtilisateur = :idUser
WHERE idContract = :idContract

How to run it for each checkbox checked from my form ?

EDIT :
Table generating :

$(document).ready( function () { 
        $('#ra').change(function() {
            if($('#ra').val()) {
            $.ajax({ 
                type: "GET",
                url: "jsonDevisUtilisateur.php?ra=" + $('#ra').val(), 
                success: function(data) {
                        var table = "<table><tr><td>Numéro</td><td>Client</td><td>Site</td><td>Libellé</td><td></td></tr>"
                    for(var i=0; i<data.length; i++) {
                        table += "<tr><td>" + data[i].numDevis + "</td>";
                        table += "<td>" + data[i].client + "</td>";
                        table += "<td>" + data[i].site + "</td>";
                        table += "<td>" + data[i].libelle + "</td>";
                        table += "<td><input type='checkbox' value='"+data[i].id + "' name='"+data[i].id + "'></td></tr>"
                    }
                        table +="</table>";
                    document.getElementById('devis').innerHTML = table+"<br/><br/>";

                }       
            });
            } else document.getElementById('devis').innerHTML = "";
        });
    });




mercredi 29 avril 2015

accepting input using check_box in rails

I'm a beginner working my way through a rails tutorial. An assignment consists of adding questions to a page (which can be edited and updated/deleted). I'm trying to get my Question form to accept input from a check_box as to whether the question was answered (to include in the Update section).

I have read documentation on check_box here and and here, and see that I would need check_box(object_name, method, options = {}, checked_value = "1", unchecked_value = "0"). However, I am unsure as to where I would use that in my form, and what I would pass as object_name, method and options. Any pointers will be much appreciated!

Controllers:

class QuestionsController < ApplicationController
  def index
    @questions = Question.all
  end

  def new
    @question = Question.new
  end

  def create
    @question = Question.new(params.require(:question).permit(:title, :body))
    if @question.save
      flash[:notice] = "Question was saved."
      redirect_to @question
    else
      flash[:error] = "There was an error saving the post. Please try again."
      render :new
    end 
  end

  def show
    @question = Question.find(params[:id]) 
  end

  def edit
    @question = Question.find(params[:id])
  end

  def update
    @question = Question.find(params[:id])
    if @question.update_attributes(params.require(:question).permit(:title, :body))
      flash[:notice] = "Question was updated"
      redirect_to @question
    else
      flash[:error] = "There was an error saving your post. Please try again."
      render :edit
    end
  end

  def destroy
    @question = Question.find(params[:id])
    @question.destroy
    redirect_to questions_path
    flash[:notice] = "The question has been deleted."
  end
end

show view:

<h1><%= @question.title %></h1>

<%= link_to "Edit", edit_question_path(@question), class: 'btn btn-success' %>

<%= link_to "Delete", @question, method: :delete, data: { confirm: "Are you sure?" }, class: 'btn btn-success' %>

<p><%= @question.body %></p>

edit view:

<h1>Edit and Update Question</h1>

<div class="row">
  <div class="col-md-4">
    <p>Guidelines for questions</p>
    <ul>
      <li>Stay on topic.</li>
    </ul>
  </div>
  <div class="col-md-8">
    <%= form_for @question do |f| %>
      <div class="form-group">
        <%= f.label :title %>
        <%= f.text_field :title, class: 'form-control', placeholder: "Enter post title" %>
      </div>
      <div class="form-group">
        <%= f.label :body %>
        <%= f.text_area :body, rows: 8, class: 'form-control', placeholder: "Enter post body" %>
      </div>
      <div class="form-group">
        <%= f.submit "Save", class: 'btn btn-success' %>
        <%= link_to "Delete", @question, method: :delete, data: { confirm: "Are you sure?" }, class: 'btn btn-success' %>
      </div>
    <% end %>
  </div>

</div>




How does css checkbox hack work?

I just came across the switch toggle button which is created only using css. It known as the checkbox hack.

For those who doesn't know what a checkbox css hack is, Please read it here

http://ift.tt/1bUhgkY

I tried it out and it was working perfectly fine. But I didn't understand how this is working because we are not clicking on the checkbox.

So I have 2 questions

  1. How is this working ?

  2. Instead of absolute positioning I tried it with

    display: none;

It still worked. Does this method have any drawbacks?




Show DIV based on select list value and checked checkboxes

i have this form:

<form action="ServletAjoutEns" name="inscription" method="post">

<select name="grade" onchange="validation()">
           <option value="0">--Selectionner un grade--</option>
           <option value="Professeur">Professeur</option>
           <option value="Maitre de conférences">Maitre de conférences</option>
           <option value="Maitre assistant">Maitre assistant</option>
           <option value="Assistant">Assistant</option>

 </select>

      <input type="checkbox" id="departement" name="departement" value="multimedia" onclick="validation()"> Multimédia

     <input type="checkbox" id="departement" name="departement" value="reseaux" onclick="validation()"> Réseaux

     <input type="checkbox" id="type" name="type" value="cours" onclick="validation()"> Cours

     <input type="checkbox" id="type" name="type" value="tp" onclick="validation()"> TP
</form>

i want when the item selected is different from '0' and any of the 2 checkboxes 'departement' is checked and the same with 'type' then i want to show a div with id='btn'.

i wrote this javascript function:

function validation() {
if(document.inscription.grade.value!="0" && document.getElementById("departement").checked == true && document.getElementById("type").checked == true)
    document.getElementById('btn').style.display = 'block';
else
    document.getElementById('btn').style.display = 'none';

}

but it works only when all the checkboxes are checked, how can i make it work when at least one of each checkbox items is checked




Grouping CheckBoxes in XAML

I have a ListView which has an item template of a UserControl

This User Control decides which type of control to display for the template for each individual list item (Radio, or Checkbox).

<ListView Visibility="Collapsed"
          ItemsSource="{Binding Collection}"
          SelectionMode="None"
          Grid.Row="1">
          <ListView.ItemTemplate>
              <DataTemplate>            
                   <local:ucMyUserControl/>  
               </DataTemplate>
          </ListView.ItemTemplate>
</ListView>

So, in my user control based on the logic in the code behind, I display one of these

    <CheckBox  x:Name="chkOption"
               Content="{Binding Text}" 
               Visibility="Collapsed"
               />

    <RadioButton x:Name="rdoOption"
                 Content="{Binding Text}"
                 GroupName="radioGroup"                   
                 Visibility="Collapsed"
                 />

The problem I have is, the check boxes are acting like Radio boxes, in that if you select one, and then a second, the first one gets unchecked. The radio boxes are working just as expected but I can't work out what's going wrong. Do the Check boxes somehow need to be in a group like the radio boxes or is it something else?




jQuery Capture Checkbox in UI Dialog Box

Based upon a checkbox, I pop a jquery UI dialog box. The content of the dialog box is dynamically built from a db. Each row has a check box for selection.

I'd like to trigger additional functionality based on clicking one of the check boxes. In the dynamically created table, each check box has a class of "promoteSelect".

Here's the code I have for the jQuery side of things.

// Handle selecting rows from Promotion Sheet Selection Table
$(".promoteSelect").on("change", function() {
    if(this.checked) {
        var env = $("#selectedEnv").val().toUpperCase();
        var promo_key = $(this).val();
        alert(promo_key);
        buildRepoTable(promo_key, env);
    }
});

Any ideas?




Select CheckBox of all ListViewItem

I got a ListActivity with list items I've created. Each item got a CheckBox in it. In addition, the layout got a button which is suppose to simply check all the check boxes, yet it's not working even though the OnClickListener of the button is being called.

This is the button's OnClickListener:

private OnClickListener selectAllButtonOnClickListener = new View.OnClickListener()
{
    View listItem;
    CheckBox cb;

    @Override
    public void onClick(View v)
    {
        int itemCount = myList.getCount();
        for (int i = 0; i < itemCount; i++)
        {
            listItem = myList.getAdapter().getView(i, null, null);
            cb = (CheckBox) listItem.findViewById(R.id.the_checkBox);
            cb.setChecked(true);
        }

    }

};

Is there something wrong with how I'm trying to check all the checkboxes?




Dynamically load checkbox to checked and unchecked AngularJS

I am new to AngularJS and I am trying to dynamically load checkboxes based on a value coming from a server. I am able to pull in titles from the server but I am unable to assign the checkboxes true and false.

enter code here Show Empty Label
True

Any help will be appreciated!

I have attached a JSFiddle.

http://ift.tt/1In8uIf




Javascript checkbox toggle div hide show

I am looking to have a checkbox (Football) that when

Unchecked:

  • displays one DIV (FootballChoice) containing a label image for the checkbox that changes with mouseover

Checked:

  • hides the DIV (FootballChoice)
  • shows a hidden DIV (FootballChecked) that contains an alternate label image
  • shows another hidden DIV (FootballTeams).

When unchecked again, this needs to return to it's original state.

Alternatively if anyone knows how to change the label image when checked to the same as the one specified in the mouseover element here, that would also be a usefull altetrnative?

Thank you in advance.

<script type="text/javascript" src="http://ift.tt/IJSC3o"></script>
<script type="text/javascript">
  
  $(document).ready(function(){
    $('input[type="checkbox"]').click(function(){
      
      if($(this).attr("value")=="FootballTeams"){
        $(".FootballTeams").toggle();
        $(".FootballChecked").toggle();
        $(".FootballChoice").toggle();
        
      }
    });
  });

</script>
.FootballChecked {
  display: none;
}

.FootballChoice {
  display: show;
}

.sport {
  display: none; 
  border: 1px dashed #FF3333; 
  margin: 10px; 
  padding: 10px; 
  background: #003366;
}
<input id="Football" type="checkbox" value="FootballTeams">

<div class="FootballChoice">
  <label for="Football" class="FootballChoice">
    <img src="http://ift.tt/1J8vwAP" onmouseover="this.src='http://ift.tt/1GHmq0B';"                  onmouseout="this.src='http://ift.tt/1J8vwAP';" alt="Football" title="Football">
  </label>
</div>
          
<div class="FootballChecked">
  <label for="Football">
    <img src="http://ift.tt/1GHmq0B" alt="Football" title="Football">
  </label>
</div>

<div class="sport FootballTeams">
  Football Teams here
</div>



Fill Form in Play Framework (Scala)

I'm making checkboxes and using Scala, I found nice example but in Java. But I couldn't convert it to Scala. This is Java code:

Form<StudentFormData> formData = Form.form(StudentFormData.class).fill(studentData);

Scala's play.api.data.Form class doesn't have "fill" and "form" methods like Java's play.data.Form. How I can create Form in Scala?




VBA multiple checkboxes to control multiple pivot tables

again I need little help which I will greatly appreciate.

Basically, on my dashboard page I have couple of checkboxes that control numerous of pivot tables in the background.

I have checkboxes that are called "definite", "tentative", "pending,", ... and also corresponds to values in pivot fields.

and I have numerous of pivot tables called: "Hidden_1" or "Hidden_2" in different sheets but all with the same structure.

My idea was that If someone checked "definite", it will be selected in all pivot pivot tables in fields called "Status". If someone "unchecked" this checkbox, the pivots will react.

To do so I used a code that I create before and it was working well:

    Sub checkbox1()
Application.ScreenUpdating = False
On Error Resume Next  
Dim pt As PivotTable, wks As Worksheet
For Each wks In ActiveWorkbook.Worksheets
    For Each pt In wks.PivotTables
        With pt
            If .Name = "Hidden_1" Or .Name = "Hidden_2" Then
                .PivotFields("Status").CurrentPage = "definite"
            End If
        End With
    Next pt
Next wks 
Application.ScreenUpdating = True 
End Sub

However, this code selects only one value, so I can't have selected both "definite" and "pending" if someone checked those boxes. Right now all checkboxes has a separate code assigned where only .CurrentPage = "checkboxname" was changed..

I have two questions:

1) what is the best way to select multiple values. E.g. if checked boxes "definite" and "pending" are checked, pivot tables should have selected two values "definite" and "pending" selected in the "Status" field

2) what is the best way to "dis-select" the value? Right now, my procedure checkbox1 is running everytime that the checkbox is clicked. And I want it to run only when I am "checking" it. Right now I am trying to link the checkbox with cell, e.g. "definite" has H10, so my code starts with the line:

If Range("H10").Value = True Then
'code to select the value in "Status" field
Else
'code to unselect the value in "Status" field
End If

I should also noted that I couldn't use ActiveX Checkbox because I had error: "cannot insert object" and I used form controls. I read that this error is somehow connected with a patch that I have installed.

Thank you all for your help, Matt




checkboxes in groupbox automatically uncheck when closing form c#

I have a groupBox in a form. In this groupBox I have three checkboxes that can be checked either one, two or three. I want the checked state to maintain after I close this form and reopen it. Is it something about the groupBox that has to be taken into consideration? How can I do this? Thank you.




Run 'change' function from another element

I have a function that runs when a checkbox is changed (works fine):

// event management
$("input.box[type=checkbox]").change(function() {
    var name = $(this).attr("name");
    $("input:checkbox[name='$name']").attr("checked", true);
    $.cookie(name, $(this).prop('checked'), {
        path: '/',
        expires: 365
    });
});

<input id="<?php echo the_ID();?>" type="checkbox" name="<?php echo the_ID();?>">

I also want to be able to change the state of the checkbox from another button:

<a onclick="$('#<?php echo the_ID();?>').attr('checked', true);">test</a>

This does change the checkbox but does not run the change function.

Any ideas? Thanks




why can't i delete a row in table from javascript?

I'm trying to build a table out from JavaScript, so far so good. The main idea is that the last column will be a checkbox, and when it will be checked the row will delete. before i delete it, i need to know what was written in this row, so i'm checking the id. for some reason it doesn't work. can someone help me? Thanks

this is the building function

 function build(name){

 var myTableDiv = document.getElementById("alertsDiv");
 var table = document.createElement('TABLE');
 var tr;
 var i, j;


  table.style="width:90%; text-align: center; font-size: 13px; border: 1px solid black; border-collapse: collapse";
  table.id = "tbAlerts";
  var tableBody = document.createElement('TBODY');
  table.appendChild(tableBody);
  tableBody.id = "tbBody";

  //users is an array 
for ( i=0; i< Users.length ; i++){
   tr = document.createElement('TR');
   tr.id = name+" row";
   //alert("this is the tr id: " +tr.id);
   tableBody.appendChild(tr);

   //the time
   td = document.createElement('TD');
   var d = new Date();
   td.appendChild(document.createTextNode( d.getHours() +":"+ d.getMinutes() +":"+ d.getSeconds() ));
   tr.appendChild(td);

   //severity
   td = document.createElement('TD');
   td.appendChild(document.createTextNode("minor"));
   tr.appendChild(td);

   //alert
   var td = document.createElement('TD');
   td.appendChild(document.createTextNode(name + " is dead"));
   tr.appendChild(td);

   //comments
   td = document.createElement('TD');
   var txtBox = document.createElement('INPUT');
       txtBox.type = 'text';
       txtBox.placeholder="comments";
   td.appendChild(txtBox);
   tr.appendChild(td);

   //Acknowledge - ***THIS IS THE IMPORTANT THING***
   td = document.createElement('TD');
   var newCheckBox = document.createElement('INPUT');
       newCheckBox.type = 'checkbox';
       rowsNum++;
       newCheckBox.name=name;
       newCheckBox.addEventListener("CheckboxStateChange", cleanAlert, false);
   td.width='10px';
   td.appendChild(newCheckBox);
   tr.appendChild(td);

 }

myTableDiv.appendChild(table);
       }
}

this is the delete function

function cleanAlert(event){
var checkbox = event.target;
var rowIndex;

rowIndex = document.getElementById(checkbox.name + " row").rowIndex;
document.getElementById("tbAlerts").deleteRow(rowIndex);

}




Fixed checkbox column in EXTJS panel(no horizontal scroll only for checkbox column)

Team,

Is Anyone aware of disabling horizontal scroll on checkbox column(1st column in grid) checkbox column remain fixed and other column's scroll properly remain working.

I tried

     bodyStyle:'overflowY: auto',

     autoScroll:false,

     setAutoScroll:false,

on particular checkboxSelectionModel and try to override property but it's not working.




Check whether the check-box is checked or not using Rails 3

I have a check-box inside a form.I need if user will checked this check-box suddenly the action will execute and it will check the check-box status whether it is checked or not using Rails 3.My form is given below.

paym.html.erb:

<%= form_for :add_payment,:url => {:action => 'add_payment' },remote: true do |f| %>
<table class="table table-bordered">
        <colgroup>
            <col class="col-md-1 col-sm-1">
            <col class="col-md-1 col-sm-1">
            <col class="col-md-3 col-sm-3">
            <col class="col-md-3 col-sm-3">
            <col class="col-md-4 col-sm-4">
        </colgroup>
        <thead>
            <tr>
                <th class="text-center"><input type="checkbox"></th>
                <th class="text-center">Sl. No</th>
                <th class="text-center">Date</th>
                <th class="text-center">Receipt No.</th>
                <th class="text-center">Amount</th>
            </tr>
        </thead>
        <tbody>
            <% @result.each do |r| %>
            <tr>
                <th class="text-center"><%= check_box_tag :check_value,nil,:id => "checkbox1-1"  %></th>
                <td class="text-center"><%= r.id %></td>
                <td class="text-center"><%= r.c_date %></td>
                <td class="text-center"><%= r.Receipt_No %></td>
                <td class="text-center"><i class="fa fa-rupee"></i><%= r.v_amount %></td>
            </tr>
            <% end %>
     </tbody>
</table>
<% end %>

paym_controller.rb:

class PaymentsController < ApplicationController
def add_payment

    end
end

Here i have a table with some value .I also need when user will checked that box 1-It will check whether check box is checked or not,2-If checked then it will get all table value corresponding to that check-box.Please help me.




Checkbox and database

I am displaying certain items and its value from the database in the form of check boxes. So the check box will be checked if the value of the item is true, else the check box is unchecked. At the same time, I am taking input from the same check boxes.

So if the user wants to check any check box, they can do so. Ans if they want to uncheck any check box, the similar changes should get reflected in the database.

How do I implement this in php. I just need to know how can I take the value from the check box which are unchecked by the users, because they appear marked as I have used checked='checked', and the corresponding value will always stay 1.




How to get value from Multi CheckBox with the same name

hello guys , I hope this is not a stupid question.

i have a multi checkbox with the same attr name like "Check" but every checkbox has deferent value

so i have create a jquery code that if i press on the checkbox will do some thing in php like this code

$(document).ready(function(){
        var NewsPaperId;
        var UserId;
        var CategoryId;
    $("input[type='checkbox']").click(function() {

        if ($(this).is(':checked')) {
            NewsPaperId= $('input[name="Check"]:checked').val();
            UserId= $(".userId").val();
            CategoryId= $(".CategoryId").val();
            alert(NewsPaperId);
            $.post("AddAndDelete.php",
                {
                    Add:1,
                    UserId: UserId,
                    NewsPaperId: NewsPaperId,
                    CategoryId:CategoryId
                },
                function(data, status){
                    alert("Data: " + data + "\nStatus: " + status);


                });

        } else {
            NewsPaperId= $('input[name="Check"]:checked').val();
            UserId= $(".userId").val();
            CategoryId= $(".CategoryId").val();

            alert(NewsPaperId);


            $.post("AddAndDelete.php",
                {
                    Delete:1,
                    UserId: UserId,
                    NewsPaperId: NewsPaperId,
                    CategoryId:CategoryId
                },
                function(data, status){
                    alert("Data: " + data + "\nStatus: " + status);
                });
        }
    });
}); 

and here is the checkbox code created by php

<?php

    $i=1;
    $sql = "SELECT NewsPaperStatus.*,UserChoises.*"
         . " FROM NewsPaperStatus"
         . " LEFT JOIN UserChoises"
         . " ON NewsPaperStatus.Id=UserChoises.NewsPaperId"
         . " WHERE NewsPaperStatus.CategoryId=$Categoryid";


                        $query = mysql_query($sql);
                        while ($row = mysql_fetch_assoc($query)){
                            if($i==1){

                                if($row['Id']==$row['NewsPaperId']){
                                    echo '<tr><th><img src="../images/NewsPaper/'.$row['Logo'].'"/></th><th><a href="">'.$row['Name'].'</a></th><th><input class="check" type="checkbox" checked="checked" name="Check" value="'.$row['Id'].'"/></th>';
                                }else{
                                    echo '<tr><th><img src="../images/NewsPaper/'.$row['Logo'].'"/></th><th><a href="">'.$row['Name'].'</a></th><th><input class="check" type="checkbox" name="Check" value="'.$row['Id'].'"/></th>';
                                }
                            }
                            else if($i==2){
                                if($row['NewsPaperId']==$row['Id']){
                                    echo '<th><img src="../images/NewsPaper/'.$row['Logo'].'"/></th><th><a href="">'.$row['Name'].'</a></th><th><input class="check" type="checkbox" checked="checked" name="Check" value="'.$row['Id'].'"/></th>';
                                }else{
                                    echo '<th><img src="../images/NewsPaper/'.$row['Logo'].'"/></th><th><a href="">'.$row['Name'].'</a></th><th><input class="check" type="checkbox" name="Check" value="'.$row['Id'].'"/></th>';
                                }
                            }
                            else if($i==3){
                                if($row['NewsPaperId']==$row['Id']){
                                    echo '<th><img src="../images/NewsPaper/'.$row['Logo'].'"/></th><th><a href="">'.$row['Name'].'</a></th><th><input class="check" type="checkbox" checked="checked" name="Check" value="'.$row['Id'].'"/></th></tr>';
                                }else{
                                    echo '<th><img src="../images/NewsPaper/'.$row['Logo'].'"/></th><th><a href="">'.$row['Name'].'</a></th><th><input class="check" type="checkbox" name="Check" value="'.$row['Id'].'"/></th></tr>';
                                }

                                $i=0;
                            }
                            $i++;
                        }
                        ?>

so the problem is when i press on any check box its work good but when i unchecked another on it take the last vale of check box (( if i press on checkbox value 16 and press on checkbox value 17 so its work good but when i want to uncheck checkbox of value 16 the value it be 17 its take the last value of checkbox i was checked

please help me 4 days and i cant resolve the problem.




Accessing value according to check box checked using Rails 3

suppose i have multiple rows in a table.Each table has one,one check box.When user will checked one check box his corresponding row value will saved in db and when user will multiple check box their corresponding row value will saved in db.

The followings are my below code.

payment.html.erb:

<div class="tbpaddingdiv2">
    <%= form_for :payment,:url => {:action => "check_type" },remote: true do |f| %>
    <div class="totalaligndiv">
      <div class="input-group bmargindiv1 col-md-6 pull-left"><span class="input-group-addon text-left"><div class="leftsidetextwidth">Type :</div></span>
      <%= f.select(:s_catagory,options_for_select([['Wood','Woods'],['Puja Samagree','GOODS'],['Sweeper','SWD'],['Photo Grapher','PHOTO'],['Burning Assistant','BURNING'],['BRAHMIN','BRAHMIN']],selected: "Type"),{},{:class => 'form-control',:onchange => ("$('#switch_car').submit()")}) %>
      </div>
      <div id="div_select" style="display:none">
      <div class="input-group bmargindiv1 col-md-6 pull-left" ><span class="input-group-addon text-left" ><div class="leftsidetextwidth">Select Vendor :</div></span>
      <div id="name-option">

      </div>
      </div>
      </div>
      <div class="clearfix"></div>
      <div class="tbpaddingdiv1 text-center">
        <%= f.submit "submit",:class => "btn btn-success",:id => "switch_car" %>
      </div>
    </div>
    <% end %>
</div>





<div class="bpaddingdiv2" id= "paymentdetail" style="display:none;">
    <div class="table-responsive" id="paymentoption">

    </div>
    <div class="totalaligndiv">
      <%= form_for :add_payment,:url => {:action => 'add_payment' },remote: true do |f| %>
          <div class="input-group bmargindiv1 col-md-6" style="margin:auto auto 10px auto; float:none;"><span class="input-group-addon text-left"><div class="leftsidetextwidth">Payment Type :</div></span>
          <%= f.select(:p_catagory,options_for_select([['Cash','Cash'],['Cheque','Cheque']],selected: "Type"),{},{:class => 'form-control',:onchange => ("$('#switch_car11').submit()")}) %>
          </div>
          <div class="clearfix"></div>
          <div class="totalaligndiv" id="payment-main" style="display:none;" >
              <div id="payment-child" >
              </div>
          </div>
          <div class="tbpaddingdiv1 text-center">
            <%= f.submit "Add to payment",:class => "btn btn-success",:id => "switch_car11" %>
          </div>
          <div class="clearfix"></div>
          <% end %>
    </div>

_paymentdetails.html.erb:

<table class="table table-bordered">
        <colgroup>
            <col class="col-md-1 col-sm-1">
            <col class="col-md-1 col-sm-1">
            <col class="col-md-3 col-sm-3">
            <col class="col-md-3 col-sm-3">
            <col class="col-md-4 col-sm-4">
        </colgroup>
        <thead>
            <tr>
                <th class="text-center"><input type="checkbox"></th>
                <th class="text-center">Sl. No</th>
                <th class="text-center">Date</th>
                <th class="text-center">Receipt No.</th>
                <th class="text-center">Amount</th>
            </tr>
        </thead>
        <tbody>
            <% @result.each do |r| %>
            <tr>
                <th class="text-center"><input type="checkbox" id="checkbox1-1" name="checkbox1-1"></th>
                <td class="text-center"><%= r.id %></td>
                <td class="text-center"><%= r.c_date %></td>
                <td class="text-center"><%= r.Receipt_No %></td>
                <td class="text-center"><i class="fa fa-rupee"></i><%= r.v_amount %></td>
            </tr>
            <% end %>
     </tbody>
</table>

payment_controller.rb:

class PaymentsController < ApplicationController

    def payment
        @payment=Vendor.new
        @add_payment=AddPayment.new
        respond_to do |format|
            format.html 
            format.js
        end

    end
    def check_type  
        if params[:commit]=="submit"
            @vendor_type = PaymentVendor.where(:v_name => params[:v_name]).map{|v|[v.v_catagory ,v.Receipt_No]}
            #@vendor_type = PaymentVendor.where(:v_name => params[:v_name]).pluck(:v_catagory)
            output=[]
            @result=[]
            @vendor_type.each do |i|
              if i.first == params[:payment][:s_catagory]
                output << i[1]
              end  
            end  
            output.each_with_index{|val, index|
               #puts "#{val} => #{index}" 
               #puts output1[index]
               @result << PaymentVendor.find_by_Receipt_No(output[index])


            }
        else
            @v_name=Vendor.where(:s_catagory => params[:payment][:s_catagory] ).pluck(:v_name)
        end
    end
    def add_payment
        if params[:commit]
          @add_payment=AddPayment.new(params[:add_payment])
        else
            if params[:add_payment][:p_catagory]=="Cheque"

            end
        end
    end
end

As you can see all are ajax call that table is render on the payment.html.erbpage.When user will checked the check box and submit the formall data belongs to that check box will saved in db through add_payment action.Please help me.




Get Selected check box items from a click of a button

How can I go about getting checked check box item's ID in a repeated list from a click of a button and add items to a variable / Array for later use?

html:

<div ng-controller="movieController">
    <ul>
        <li ng-repeat="m in Movies">
                <input id="chkBox-{{ m.MovieID }}"
                       type="checkbox"
                />
        </li>
    </ul>
</div>

web API:

[{"MovieID":1,"Duration":"1:30:00"},
{"MovieID":2,"Duration":"1:30:00"},
{"MovieID":3,"Duration":"1:30:00"}]




mardi 28 avril 2015

Android checkbox list selection issue

i have a list and using adapter i am adding items to it.When i select first item of check box automatically first item after scroll gets selected and so the items of subsequent scrolls.what is the issue how to solve.

<RelativeLayout xmlns:android="http://ift.tt/nIICcg"
    xmlns:tools="http://ift.tt/LrGmb4"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context="com.example.messagecleaner.MainActivity" >
<LinearLayout 
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="vertical"
    >
    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Select the addresses don't want to see" />
    <ListView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:id="@+id/idAddressList" 
        >        
    </ListView>
</LinearLayout>
</RelativeLayout>



enter code here

package com.example.messagecleaner;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.ListIterator;

import android.support.v7.app.ActionBarActivity;
import android.telephony.SmsManager;
import android.text.AndroidCharacter;
import android.content.Context;
import android.content.IntentFilter;
import android.database.Cursor;
import android.net.Uri;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.CheckBox;
import android.widget.CheckedTextView;
import android.widget.CompoundButton;
import android.widget.CompoundButton.OnCheckedChangeListener;
import android.widget.ListView;



public class MainActivity extends ActionBarActivity {
    ListView lstAddress;
    Context mContext;
    List<String> arrAddress;

    class MyAddressAdapter extends ArrayAdapter<String>
    {
        List<String> address;
        public MyAddressAdapter(Context context, int resource,
                List<String> objects) {
            super(context, resource, objects);
            address=objects;
            System.out.println("---->"+address.size());
            // TODO Auto-generated constructor stub
        }

        @Override
        public View getView(int position, View convertView, ViewGroup parent) {
            // TODO Auto-generated method stub
        //  return super.getView(position, convertView, parent);
            View row=convertView;
            if(row==null)
            {
                LayoutInflater inflator= getLayoutInflater();
                row = inflator.inflate(R.layout.addresscheckboxlistitem, parent, false);
                CheckBox ctv=(CheckBox) row.findViewById(R.id.idAddressCheckTextView);
                ctv.setOnCheckedChangeListener(new OnCheckedChangeListener() {

                    @Override
                    public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                        // TODO Auto-generated method stub
                        System.out.println("Position "+ isChecked);
                    }
                });
                //ctv.setText(arrAddress[position]);
                System.out.println(address.get(position));
                ctv.setText(address.get(position)); 


            return row;
            }
            else
            {

                    CheckBox ctv=(CheckBox) row.findViewById(R.id.idAddressCheckTextView);
                    ctv.setOnCheckedChangeListener(new OnCheckedChangeListener() {

                        @Override
                        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                            // TODO Auto-generated method stub

                        }
                    });
                    System.out.println(address.get(position));
                    ctv.setText(address.get(position));
                    return row;

            }
        }       

    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        lstAddress=(ListView) findViewById(R.id.idAddressList);
        mContext=this;
        arrAddress= new ArrayList<String>();
        Cursor cursor = getContentResolver().query(Uri.parse("content://sms/inbox"), null, null, null, null);
        //arrAddress=new String[cursor.getCount()];
        int i=0;
        if (cursor.moveToFirst()) { // must check the result to prevent exception
            do {
               String msgData = "";
               for(int idx=0;idx<cursor.getColumnCount();idx++)
               {

                   if(cursor.getColumnName(idx).equals("address"))
                   {
                       String msgAddress=cursor.getString(idx);
                       //msgData += " " + cursor.getColumnName(idx) + ":" + cursor.getString(idx);
                   //    System.out.println(msgAddress);
                       //arrAddress[i]=msgAddress;
                       if(arrAddress.contains(msgAddress))
                       {

                       }
                       else
                       {
                           arrAddress.add(msgAddress);


                       }
                   }
               }
               // use msgData
               i++;
            } while (cursor.moveToNext());
            System.out.println("Address array "+arrAddress.size());
            lstAddress.setAdapter(new MyAddressAdapter(mContext, android.R.layout.simple_list_item_1, arrAddress));
        } else {
           // empty box, no SMS
        }
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.main, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle action bar item clicks here. The action bar will
        // automatically handle clicks on the Home/Up button, so long
        // as you specify a parent activity in AndroidManifest.xml.
        int id = item.getItemId();
        if (id == R.id.action_settings) {
            return true;
        }
        return super.onOptionsItemSelected(item);
    }
}




Query Selected Items using checkbox in MVC

I like to ask if how would it be possible that the selected items in the checkbox will be used in making linq query in MVC. I have this one in my view where in I displayed all the possible options in which the user will just simply select the types of softwares that will be used to generate reports.

@using (Ajax.BeginForm("Create_Report", "Softwares",
            new AjaxOptions
            {
                HttpMethod = "POST",
                InsertionMode = InsertionMode.Replace,
                UpdateTargetId = "target2"
            })) 
        { 
            @Html.ValidationSummary(true)
             <p>For A Reports: Kindly check softwares to create reports.</p><br />
            foreach (var item in Model) { 
                <input type="checkbox" value="@item.software_name" name="software_type"/>@item.software_name
                <br />
            }


            <input type="submit" value="Create Report"/>

        }

After that, I want that the selected software types will be used in the query like for example if the user selects Adobe Pro, Adobe Illustrator, MS Visio, and Acrobat, the query should go like "Select from Software _table where software__type = "Adobe Pro" && software_type ="Adobe Illustrator && "so fort.

Is there any ways to shorten the query using the selected items from the checkbox? Any help is much appreciated.




Can't Check Checkbox in jQuery Collapsable Element

I'm using the following code to allow for an accordion effect on a series of table rows.

        $('.accordian-body').on('show.bs.collapse', function () {
            $(this).closest("table")
                .find(".collapse.in")
                .not(this)
                .collapse('toggle')
        });

Inside the collapsed rows I also have a series of checkboxes, to allow for options to be selected:

        <div style="float:right;margin-top:-5px;" class="checkbox check-primary checkbox-circle">
           <input id="checkbox1" type="checkbox" checked="checked" value="1">
           <label for="checkbox1"></label>
         </div>

These checkboxes cannot be checked or unchecked, even if not disabled, although the mouse pointer will chance to indicate a clickable element is there.

How can I re-enable the checkboxes?

Thanks!




Have a pop up window with checked box list when click on an icon

I have a table in my page, for which I get the data from database. In some cells I have an edit icon.I want when users clicks on it, they see a pop up window.

In the pop up window, I want to show three option(check boxes), that user can select only one of them, and then click on OK button, and return the value of the selected option to the data variable.(as you see in the code below)

I have to mention, that right now when the user clicks on the edit icon, some information are sent to another file. Because I need to update database.

   $(".SSO").click(function () {
    var id = $(this).attr("data-id");
    var data= HERE I NEED TO GET THE VALUE OF THE SELECTED OPTION IN THE POP UP WINDOW
  }

So SSO is the value of class attribute for the image icon. data-id value helps to update the correct record in the database.

Can anyone give me help me with that.




JQuery not setting variable when checkbox is checked

Howdie do,

It's very simple, but I can't see my mistake. When the user clicks the checkbox, the variable isEmployee needs to be set to true. I then pass that variable to a JSON array, but some reason, no matter what I do, the isEmployee variable isn't being set.

<label for="EmployStats">Current Employee: </label><input type="checkbox" id="EmployStats" checked />

var isEmployee = false;

$('#EmployStats').change(function()
{
     if(this.checked)
     {
        isEmployee = true;
      }
});

data = {'Employ_Status':isEmployee};  

However, when I hit my submit button, the header still is showing Employ_Status as false even when the checkbox is clicked.

I can't for the life of me see what is wrong with this

UPDATE: The reason the data array is set after the checkbox being set is due to the data arrary only being submitted after other fields have been validated:

   if(submit == true) //If data is present, then prepare email and user values to be submitted to .php page
                                {
                                        var results;
                                        data = {'Employ_name': $('#EmployName').val(), 'Employ_num': $('#EmployNumber').val(), 'Employ_phone': $('#Phone').val(), 'Employ_address': $('#Address').val(), 'Employ_city': $('#City').val(), 'Employ_state': $('#State').val(),'Employ_zip': $('#Zip').val(), 'Employ_Status':isEmployee}; //Add input to JSON array
                                        $.post("success.php", data, function(ReturnedData) //post data via ajx to success.php and retrieve response
                                        {
                                                if(ReturnedData.Type == 'Error') //If error returned, display error message
                                                {
                                                        results = '<h1 class="error">'+ReturnedData.Message+'</h1>';
                                                }
                                                else if(ReturnedData.Type == 'Success') //If success returned, display message and remove submit button
                                                {

                                                        results = '<h1 class="success">'+ReturnedData.Message+'</h1>';
                                                }
                                                $('#DataHolder').html(results);
                                        }, 'json');
                                }
        });




onchange event on checkbox always shows this.value = on

An input of type checkbox when fires its onchange event the this.value is always set to on even when the checkbox is ticked off in which case I'd expect it to be off

Is this the intended behavior?

<input type="checkbox" onchange="alert(this.value)">



If checkbox in a form is ticked add it to the resulting div class

I am using a Wordpress plugin called Multi Rating Pro. When a user submits a rating on the page the result appears in a separate div on the same page.

I want to (as simply as possible) insert my own checkbox into the rating form and if its ticked, output a value in the resulting div class.

For example, inside the rating form I would add something like -

<input type="checkbox" name="anon" value="yes"> Rate anonymously

Then in the resulting div I would be looking for the class of 'yes' to be added to the div if the checkbox was checked on submission, like -

<div class="rating-result yes"></div>

How would I go about doing this? I assume the way in which he form is submitted would play a part but am unsure of its workings...




Javascript to loop through asp checkboxes to see if any are checked

I am having an issue looping though asp checkboxes in an ascx file to see each individual element's "state" (checked or not). Here is my code:

<asp:ListView runat="server" ID="lvApplicationForms" OnItemCommand="lvAttachedDocuments_OnItemCommand"
    DataKeyNames="FormID" OnPreRender="lvApplicationForms_PreRender" OnItemDataBound="lvApplicationForms_ItemDataBound">
    <ItemTemplate>
        <tr class="<%# (Container.DisplayIndex + 1 )% 2 == 0 ? "EvenRow" : "OddRow" %>" data-formname='<%#Eval("FormName")%>'>
            <td class="fieldName_td" style="text-align: center">
                <asp:CheckBox ID="cbIsExposed" runat="server" Style="text-align: center" onclick="javascript:return CheckedChange(this)" OnChecked='<%# Eval("IsPublished") %>'
                    Enabled='<%# CanCounterSignAndExpose && Convert.ToBoolean(Eval("CanBePublished")) %>' />
            </td>
            </tr>
    </ItemTemplate>
    </asp:ListView>

Essentially my issue is that I have a save button on the page that I want enabled only if at least one element in the checkboxes is checked. If none are, keep the save button disabled. I know how to disable the save button, I just don't know how to loop though the checkboxes to get their "state".




Get information checkbox and EditText within a LinearLayout

I have a checkbox and EditText that generated dynamically by a query

This is the method that generates the checkbox and EditText and adds it to LinearLayout

private void create_form() {
    JSONObject json = null;
    int count = 0;
    lm = (LinearLayout) findViewById(R.id.linearMain);
    int seccion = Integer.parseInt(conf.get_id_seccion());
    int tipo_solicitud = Integer.parseInt(conf.get_tipo_solicitud());
    JSONObject jobj = obj_sqlite.get_form(seccion, tipo_solicitud);


    try {
        count = Integer.parseInt(jobj.getString("cont"));
        json = new JSONObject(jobj.getString("json"));
    } catch (Exception e) {
        Log.e("getParams", e.getMessage());
    }

    for (int x = 1; x <= count; x++) {

        try {
            JSONObject json_row = new JSONObject(json.getString("row" + x));

            CheckBox chb = new CheckBox(this);
            chb.setText(json_row.getString("pregunta"));
            chb.setId(json_row.getInt("pregunta_verificacion_supervision"));
            chb.setTextSize(10);
            chb.setPadding(8, 3, 8, 3);
            chb.setTypeface(Typeface.SERIF, Typeface.BOLD_ITALIC);
            chb.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT,
                    LayoutParams.WRAP_CONTENT));

            lm.addView(chb);

            EditText et = new EditText(this);
            et.setHint("observaciones");
            et.setId(json_row.getInt("pregunta_verificacion_supervision"));
            et.setTextSize(10);
            et.setPadding(8, 3, 8, 3);
            et.setTypeface(Typeface.SERIF, Typeface.BOLD_ITALIC);
            et.setInputType(android.text.InputType.TYPE_TEXT_FLAG_IME_MULTI_LINE);
            et.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT,
                    LayoutParams.WRAP_CONTENT));

            lm.addView(et);


        } catch (Exception e) {
            Log.e("getParams", e.getMessage());
        }
    }
}

Now I need to get all this checkbox selected along with your EditText to keep them in the table

this is my xml

<RelativeLayout xmlns:android="http://ift.tt/nIICcg"
xmlns:tools="http://ift.tt/LrGmb4"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.example.php_mysql_sqlite.Formulario_verificacion_supervision" >

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="@string/title_activity_preguntas_revision" android:id="@+id/textView1"/>

<ScrollView
    android:id="@+id/scrollView1"
    android:layout_width="285dp"
    android:layout_height="330dp"
    android:layout_marginTop="30dp" >

    <LinearLayout
        android:id="@+id/linearMain"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_alignParentTop="true"
        android:background="@color/White"
        android:orientation="vertical" >
    </LinearLayout>
</ScrollView>

<Button
    android:id="@+id/bt_regresar"
    style="?android:attr/buttonStyleSmall"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:layout_alignRight="@+id/scrollView1"
    android:onClick="regresar"
    android:text="@string/bt_regresar" />

<Button
    android:id="@+id/bt_guardar"
    style="?android:attr/buttonStyleSmall"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignBaseline="@+id/bt_finalizar"
    android:layout_alignBottom="@+id/bt_finalizar"
    android:layout_alignLeft="@+id/scrollView1"
    android:text="@string/bt_guardar"
    android:onClick="guardar" />

<Button
    android:id="@+id/bt_finalizar"
    style="?android:attr/buttonStyleSmall"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignBaseline="@+id/bt_regresar"
    android:layout_alignBottom="@+id/bt_regresar"
    android:layout_marginLeft="31dp"
    android:layout_toRightOf="@+id/bt_guardar"
    android:text="@string/bt_finalizar"
    android:onClick="finalizar" />

and this is one image as is currently http://ift.tt/1QFYvRO

by a method that is called on a button click, making the action to get the data

Thanks to all

PS: If you give me negative points, leave a comment of that because it has happened to me in the past and can not do wrong




PHP saving and re fetching checkbox values

I am an electronic engineering student. I have a doubt concerning Web development. I have to make a web site for doctors to enter patients data. Most of the data are in check box format. My question is regarding saving and re fetching check box status from the data base, so that the user can see what all are checked previously and what all are not checked when he log's in back the next time. And also how can i replace the check-box status in database if i change the status. I searched about this in internet but there is no much data concerning this. So if anyone could guide me or give me a link or example codes where i can look and study, it will be a great help for me.




Placing png in shape

I want to customize checkbox in Android app and I have checkmark image for checkbox in png file. Is it possible to place png into shape? And if yes then how could I do it? The shape I would like to use as checbox's background.




Pass checkbox value to controller from gsp in grails

I've a checkbox in my Grails application:

<g:checkBox name="reservationAvailable" value="${cafeeInfo.isReservationAvailable}"/>

It must be uncheked if isReservationAvailable boolean-value is false and checked if it's true. When I click on unchecked checkbox, it become checked, then I send a form, but in logs of controller I get false checkbox value. When I update view page, checkbox become empty again. Using parsing such as:

oldCafeeInfo.isReservationAvailable = Boolean.parseBoolean(params['reservationAvailable'])

doesn't solve my issue. How to solve it?




How to get the details of Super parent and parent checkboxes in Jquery Checkbox Hierarchy

I have a hierarchy of checkboxes this way,

fiddlehttp://jsfiddle.net/penk/k3cqny72/

I want to find whether the parent and super parent checkboxes are checked, on clicking the Click Me Button and have to show an alert saying, please select the corresponding Parent to proceed further.

a) If parents and super parents are checked then no need show warning alert.

b) If parent is not checked or if super parent is not checked then we need to show a warning alert.

(I.e, we need to check Super parent if there is an 3 level hierarchy (then no need to check parent , we need to check parent if there is single level hierarchy (as there is no super parent.)

I.e, in the above example,

1) If Office2/3/1 is selected the it should say Please select Office.(Parent)

2) If Assistant Manager 1/1/1 is selected then it should say Please select Vice President(Super Parent not parent Manager 1)

3) If Assistant Manager 2/2/2 is selected it should say , please select Vice President(i.e,super parent In this case no need to check parent Manager 2)

4) If Manager1/2 is selected the it should say Please select Parent Vice Parent.(Parent)

5) if Administration2/3/1 is selected it should say please select parent Administration.

6)if lABOUR 3/2/1Manager 1 is selected it should say please select parent MD. This should be continued till the end of the hierarchy .

As i have shown in the HTML, this is an dynamic checkbox hierarchy and it can be in any number.So, we should check each and every tree on clicking the click me button.

I have done select and unselect part, but as I am new to Jquery, I am not able to code with the parets and childs Details

I tried doing it storing in an array this way, Some how it is not working.

Can some one help me in this issue.?

The final alert should be consolidated one , i.e, alert should be this way for the above 3 conditions, please select Please select Administration ,Please President ,please select President.

There is no .css class defined for these checboxes,only way of differentiating each and every checkbox is is by using Unique id attribute .

cODE - html
============

    <ul>
        <li>
            <input type="checkbox" />Office
                            <ul>
                                <li>
                                    <input type="checkbox" />Office1</li>
                                <li>
                                    <input type="checkbox" />Office2</li>
                                <li>
                                    <input type="checkbox" />Office 3</li>
                            </ul>
        </li> 
    </ul>        
            <ul>
                <li>
                    <input type="checkbox" />Vice President
                    <ul>
                        <li>
                            <input type="checkbox" />Manager 1
                            <ul>
                                <li>
                                    <input type="checkbox" />Assistant Manager 1</li>
                                <li>
                                    <input type="checkbox" />Assistant Manager 1</li>
                                <li>
                                    <input type="checkbox" />Assistant Manager 1</li>
                            </ul>
                        </li>                   
                    </ul>
                </li>
        </ul>      

    <ul>            
                    <ul>
                        <li>
                            <input type="checkbox" />Manager 2
                            <ul>
                                <li>
                                    <input type="checkbox" />Assistant Manager 2</li>
                                <li>
                                    <input type="checkbox" />Assistant Manager 2</li>
                                <li>
                                    <input type="checkbox" />Assistant Manager 2</li>
                            </ul>
                        </li>                   
                    </ul>            
        </ul> 
    <ul>
                <li>
                    <input type="checkbox" />CEO
                    <ul>
                        <li>
                            <input type="checkbox" />Manager 1
                            <ul>
                                <li>
                                    <input type="checkbox" />Assistant  1</li>
                                <li>
                                    <input type="checkbox" />Assistant  2</li>
                                <li>
                                    <input type="checkbox" />Assistant  3</li>
                            </ul>
                        </li>                   
                    </ul>
                </li>
        </ul>  

     <ul>
                          <ul>
                        <li>
                            <input type="checkbox" />Manager 2
                            <ul>
                                <li>
                                    <input type="checkbox" />Assistant  4</li>
                                <li>
                                    <input type="checkbox" />Assistant  5</li>
                                <li>
                                    <input type="checkbox" />Assistant  6</li>
                            </ul>
                        </li>                   
                    </ul>            
        </ul> 

    <ul>
        <li>
            <input type="checkbox" />Administration
                            <ul>
                                <li>
                                    <input type="checkbox" />Administration1</li>
                                <li>
                                    <input type="checkbox" />Administration2</li>
                                <li>
                                    <input type="checkbox" />Administration3 3</li>
                            </ul>
        </li> 
    </ul>        
            <ul>
                <li>
                    <input type="checkbox" />President
                    <ul>
                        <li>
                            <input type="checkbox" />Manager 1
                            <ul>
                                <li>
                                    <input type="checkbox" />Accountant 1</li>
                                <li>
                                    <input type="checkbox" />Accountant 1</li>
                                <li>
                                    <input type="checkbox" />Accountant 1</li>
                            </ul>
                        </li>                   
                    </ul>
                </li>
        </ul>      

    <ul>            
                    <ul>
                        <li>
                            <input type="checkbox" />Manager 2
                            <ul>
                                <li>
                                    <input type="checkbox" />Assistant Manager 2</li>
                                <li>
                                    <input type="checkbox" />Assistant Manager 2</li>
                                <li>
                                    <input type="checkbox" />Assistant Manager 2</li>
                            </ul>
                        </li>                   
                    </ul>            
        </ul> 
    <ul>
                <li>
                    <input type="checkbox" />MD
                    <ul>
                        <li>
                            <input type="checkbox" />Manager 1
                            <ul>
                                <li>
                                    <input type="checkbox" />lABOUR 1</li>
                                <li>
                                    <input type="checkbox" />lABOUR 2</li>
                                <li>
                                    <input type="checkbox" />lABOUR 3</li>
                            </ul>
                        </li>                   
                    </ul>
                </li>
        </ul>  

     <ul>
                          <ul>
                        <li>
                            <input type="checkbox" />Manager 2
                            <ul>
                                <li>
                                    <input type="checkbox" />wORKER 1</li>
                                <li>
                                    <input type="checkbox" />wORKER 2</li>
                                <li>
                                    <input type="checkbox" />wORKER 3</li>
                            </ul>
                        </li>                   
                    </ul>            
        </ul> 

    <input type="button" id="button" value="Click Me" />

JS
===
    $('li :checkbox').on('click', function () {
        var $chk = $(this),
            $li = $chk.closest('li'),
            $ul, $parent;
        if ($li.has('ul')) {
            $li.find(':checkbox').not(this).prop('checked', this.checked)
        }
        do {
            $ul = $li.parent();
            $parent = $ul.siblings(':checkbox');
            if ($chk.is(':checked')) {
                $parent.prop('checked', $ul.has(':checkbox:not(:checked)').length == 0)
            } else {
                $parent.prop('checked', false)
            }
            $chk = $parent;
            $li = $chk.closest('li');
        } while ($ul.is(':not(.someclass)'));
    });


    var onClick = function() {
        alert('Hi');
    };

    $('#button').click(onClick);