jQuery's inArray method requires data type matching, too. Since the value
of any HTML element is a string, you are trying to match a number to a
string, e.g.1 === "1", which will always be false. To fix this, parse your
values as integers, ie:
var check_box_values = $('#myForm
[type="checkbox"]:not(:checked)').map(function () {
return parseInt(this.value);
}).get();
Give that a try and see if it works for you.
On Friday, November 23, 2012 10:51:02 AM UTC-5, Pedro Guimarães wrote:
>
> ***Code below: Working well.***
>
> (...)
> var check_box_values = $('#myForm
> [type="checkbox"]:not(:checked)').map(function ()
> {
> return this.value;
> }).get();
>
> *
> **Code below: Working well.***
>
> function f(check_box_values)
> {
> (...)
> var obj = jQuery.parseJSON(jsonData);
> var data = google.visualization.arrayToDataTable(obj);
>
> *
> **Code below: for cycle goes fine but if statement never starts***
>
> for (var i = 1; i < data.getNumberOfColumns()-1; i++) {
>> {
>> if ($.inArray(i, check_box_values) > -1)
>> {
>> data.removeColumn(i);
>> }
>> }
>> }
>>
>
> ***Html code: Working well.***
>
> What am I doing wrong?
> note: the check_box_values array is populated.
>
> ***edit: (eg.)***
> `getNumberOfColumns: 6`
> check_box_values array: [1,3,5]
>
--
You received this message because you are subscribed to the Google Groups
"Google Visualization API" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/google-visualization-api/-/zWEp5D_oK1wJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-visualization-api?hl=en.