lundi 28 mars 2016

How to save multiple dimention checkbox in YII Framework?

enter image description here

Help me how to script YII Framework save multiple dimention checkbox ??

Thanks




dimanche 27 mars 2016

Android Listview checkboxes get scrambled

I am making a todo list app and I use a listview. Each item has a checkbox and a textview and has it's own Task object. The problem is when I check one box, another box 10-11 rows below it gets checked too. If you continue to scroll up and down on the list the checked checkboxes spread and and soon all of them are checked. I don't understand what I'm doing wrong. Help would be very appreciated! Thanks!

Here is my ListAdapter:

public class TaskListAdapter extends BaseAdapter {

private ArrayList<Task> tasks;
private Context context;
private TinyDB tinyDB;

public TaskListAdapter(Context context, ArrayList<Task> tasks, TinyDB tinyDB){
    this.context = context;
    this.tasks = tasks;
    this.tinyDB = tinyDB;
}
@Override
public int getCount() {
    return tasks.size();
}

@Override
public Object getItem(int position) {
    return tasks.get(position);
}

@Override
public long getItemId(int position) {
    return position;
}


static class ViewHolder {
    AppCompatCheckBox checkBox;
    TextView taskTextView;
}

@Override
public View getView(final int position, View convertView, ViewGroup parent) {
    ViewHolder holder;
    if (convertView == null) {
        LayoutInflater layoutInflater = LayoutInflater.from(context);
        convertView = layoutInflater.inflate(R.layout.list_item, null);

        holder = new ViewHolder();
        holder.checkBox = (AppCompatCheckBox) convertView.findViewById(R.id.checkBox);
        holder.taskTextView = (TextView) convertView.findViewById(R.id.taskTextView);
        convertView.setTag(holder);
    } else {
        holder = (ViewHolder) convertView.getTag();
    }

    //checkbox
    int priority = tasks.get(position).getPriority();
    int[][] states = new int[][]{new int[]{-android.R.attr.state_checked}, new int[]{android.R.attr.state_checked}};
    int[] redColors = new int[]{context.getResources().getColor(R.color.radioBtnRed), context.getResources().getColor(R.color.radioBtnRed),};
    int[] blueColors = new int[]{context.getResources().getColor(R.color.radioBtnBlue), context.getResources().getColor(R.color.radioBtnBlue),};
    int[] greenColors = new int[]{context.getResources().getColor(R.color.radioBtnGreen), context.getResources().getColor(R.color.radioBtnGreen),};
    if(priority == 1){
        holder.checkBox.setSupportButtonTintList(new ColorStateList(states, redColors));
    }
    else if(priority == 2){
        holder.checkBox.setSupportButtonTintList(new ColorStateList(states, blueColors));
    }
    else if(priority == 3){
        holder.checkBox.setSupportButtonTintList(new ColorStateList(states, greenColors));
    }

    holder.checkBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            tasks.get(position).setIsChecked(isChecked);
            tinyDB.putListObject(MainActivity.TASKS_FILE, tasks);
            MainActivity.collectCheckedTasks();
        }
    });

    boolean isChecked = tasks.get(position).isChecked();
    if(isChecked){
        holder.checkBox.setChecked(true);
    }

    //task title
    String title = tasks.get(position).getTitle();
    holder.taskTextView.setText(title);

    return convertView;
}

}




addClass to label if checkbox is checked, even on page refresh

How would I write the following in jQuery?:

When page load / (or "Continue" button is clicked, if makes more sense)
    Find input[type=checkbox] in each .block-container
        If input is checked
            add class to label
        If input is not checked
            remove class from label

I have a long line of checkboxes that follow this structure:

<div class="block-container">
    <div class="inner-container">
        <div class="form-group wpcf7-form-control wpcf7-checkbox checkbox-418">
            <div class="checkbox wpcf7-form-control wpcf7-checkbox checkbox-418 checked_check">
                <label class="">
                    <input type="checkbox" aria-invalid="false" value="Lorem ipsum title" name="checkbox-418" novalidate="novalidate" class="garlic-auto-save" checked="checked">
                    Lorem ipsum title</label>
            </div>
        </div>
    </div>
</div>

I had a toggleClass on them to add a color to the label when it's clicked, and a fancy checkbox icon (with the checkbox itself moved offscreen) but when the page is refreshed the class isn't applied even if the checkbox is still checked.

So if the user refreshes the page, the checkboxes they checked will remain checked, but the visual indicator (color, fancy checkbox) will appear to them to be unchecked, so they'll check it again and wind up unchecking the check.

Thanks in advance.

Edit to add something I tried:

$(document).ready(function() {
    $('.select-action').on('click',function() {
        $('.block-container input').each(function() {
            if ($("input[type=checkbox]").prop('checked')) {
                $(this).parent("label").addClass("symptomChecked");
                $(this).parent().parent().removeClass("empty_check").addClass("checked_check");
            } else {
                $("input").parent("label").removeClass("symptomChecked");
                $(this).parent().parent().removeClass("checked_check").addClass("empty_check");
            }
        });
    });
});




Selenium Webdriver: finding checkbox based on multiple row values

Good day,

I went through this site but could not find a solution for my problem and was wondering if people with more experience in Selenium could help me out. Apologies for the long post, but I wanted to make sure that I explained things properly.

I am using Java. I normally use Rational Function Tester (java) but I am trying to see if I can rewrite the code from some of the tests, to see how easy it would be to convert.

I have a table with 11 columns and 4 rows (but it could be 20 or 50 rows, it fluctuates during testing). I can read the table and its content to find the row that I want. I compare each of the first 10 cell values and, if they all match, I want to click on the checkbox that is in column 11. Otherwise, continue to the next row.

The function works properly to retrieve the values from each cell. However, when I try to click on the checkbox, it is always selecting the one that is on the first row. When I checked the attributes, I can see that all the checkboxes have the same 'name' but a different value (such as 1330361, 1330363, 1330359, etc.). Interestingly, if I do a search for all the check boxes in the row, it reports 4 of them (the number found in the whole table, not on the row).

I am probably making a very basic mistake but I cannot figure out what it is.

I use the following code to search in the table. The function receives the table row and, at this point, I am just reporting the cell values then attempt to click on the checkbox that is in the row. It is kind of a debugging function. I am not sure if it is proper to post a huge amount of code, so I will just put a short version of it, where I try to click on each of the checkbox in the table.

// Passing a specific table row to the function:
List<WebElement> columns=myRow.findElements(By.tagName("td"));
for (int iLoop = 0;iLoop < columns.size();iLoop++)
{
     System.out.println("Column " + iLoop + " : '" + columns.get(iLoop).getText().toString() + "'");
     // code to compare actual and expected values and setting of a boolean variable.

     if (iLoop == 10 && recordMatch)
     {
          tCheckbox = myRow.findElement(By.xpath("//input[@type='checkbox']"));
         System.out.println("Value is :" + tCheckbox.getAttribute("value").toString());
          tCheckbox.click();
     }

Thank you,

André




How to code checkbox validation with php

I am trying to validate the following checkboxes and output an error message for each field that isn't selected with php. Can anyone help?

<html>
<body>
<input type='checkbox' name='option[]' value='Car' >I have a Car licence<br>
                <input type='checkbox' name='option[0]' value='Motorcycle' >I have a Motorcycle licence<br>
                <input type='checkbox' name='option[1]' value='Fishing' >I have a Fishing licence<br>
                <input type='checkbox' name='option[2]' value='TV' >I have a TV licence<br>
                <input type='checkbox' name='option[3]' value='Dog' >I have a Dog licence<br><br>

  <input type="submit" name="Submit" value="submit">
</body>
</html>




Dropdown populating/creating checkboxes

Im trying to create some checkboxes based on the selected dropdown options, but seems it not working and not even creating the checkbox. And im getting confused, when/where/how i call the js with this function

/controller/file_upload.php

public function index() {
    $this->load->helper(array('form', 'url', 'html'));
    $this->load->view('template/header_view.php');
    $this->load->view('template/sidebar_view.php');
    $this->load->view('fileupload_view');

}

function getSelected() {
    $this->load->model('file_upload_model');
    $permission = $this->input->get('permission', TRUE);
    if ($permission == "seksi") {
        $permission_data = $this->file_upload_model->getSeksi();
    } else if($permission == "unit") {
        $permission_data['option_list'] = $this->file_upload_model->getUnit();
        echo json_encode($permission_data);
    }
}

/model/file_upload_model.php

function getSeksi() {
    $seksi['description'] = array('Seksi Konservasi','Kelompok Jabatan Fungsional', 'Tata Usaha');
    $seksi['abr'] = array('konservasi', 'kjf', 'tu');
    return $seksi;
}

function getUnit() {
    $unit = array('Unit Registrasi', 'Unit Pemeliharaan', 'Unit Pembibitan', 'Unit Kepegawaian', 'Unit Jasa dan Informasi', 'Unit Keuangan', 'Unit Umum');
    return $unit;
}

the view

<?php 
        $permission_options = array('semua'=>'Semua', 'seksi'=>'Seksi', 'unit'=>'Unit', 'individu'=>'Individu', 'pribadi'=>'Pribadi');
        $permission_attributes = 'aria-expanded="false" data-toggle="dropdown" class="dropdown-toggle" id="permission"';
        echo form_dropdown('permission', $permission_options, 'pribadi', $permission_attributes);
?>

codeigniter/asset/js/dropdown.js

(function() {
var httpRequest;
dropper = document.getElementById("statedrop");
dropper.onchange = function() { 
//alert(dropper.value);
makeRequest('http://localhost:8080/codeigniter/index.php/file_upload/ajaxdrop?state=' + dropper.value); 
};

function makeRequest(url) {
    if (window.XMLHttpRequest) { // Mozilla, Safari, ...
        httpRequest = new XMLHttpRequest();
    } else if (window.ActiveXObject) { // IE
        try {
            httpRequest = new ActiveXObject("Msxml2.XMLHTTP");
        } 
        catch (e) {
            try {
                httpRequest = new ActiveXObject("Microsoft.XMLHTTP");
            } 
            catch (e) {}
        }
    }

    if (!httpRequest) {
        alert('Giving up :( Cannot create an XMLHTTP instance');
        return false;
    }
    httpRequest.onreadystatechange = alertContents;
    httpRequest.open('GET', url);
    httpRequest.setRequestHeader('X-Requested-With', 'XMLHttpRequest'); 
    httpRequest.send();
}

function alertContents() {
    if (httpRequest.readyState === 4) {
        if (httpRequest.status === 200) {
            var permission_data = JSON.parse(httpRequest.response);
            var select = document.getElementById('permission');
            if(emptySelect(select)){
                for (var i = 0; i < permission_data.abr.length; i++){
                    var el = document.createElement("INPUT");
                    el.setAttribute("type", "checkbox");
                    el.value = permission_data.abr[i];
                    document.write(permission_data.description[i]);
                    var br = document.createElement("BR");
                    document.write(br);

                }
            }
        } else {
            alert('There was a problem with the request.');
        }
    }
}

function emptySelect(select_object){
    while(select_object.options.length > 0){                
        select_object.remove(0);
    }
    return 1;
}
})();

any suggestion about the mechanism how i should do it (even if its completely different, as long as it achieve the objectives), or anything would be welcomed.




How to properly create a mouse Listener for CheckBox in LibGDX Scene2D?

I've been searching online for hours and I'm new to LibGDX game development. This link was useful, but I still have not been able make my CheckBox work. How to properly implement CheckBox in LibGDX

I'm using LibGDX and I have to implement two Radio buttons in my menu.

I created two CheckBox and assigned them a style.

    check_style = new CheckBox.CheckBoxStyle();
    check_style.font = font;
    check_style.fontColor = new Color(Color.WHITE);
    check_style.checkboxOff = check_skin.getDrawable("checkbox");
    check_style.checkboxOn = check_skin.getDrawable("checkbox2");
    check_style.checked = check_skin.getDrawable("checkbox2");

I also added a listener to notice mouse clicks

    controls1Check.addListener(new InputListener() {
        public void touchUp (InputEvent event, float x, float y, int pointer, int button) {
            controls1Check.toggle();
            System.out.println("toggle");
        }
        public boolean touchDown (InputEvent event, float x, float y, int pointer, int button) {
           System.out.println("Controls1: " + controls1Check.isChecked());
           return true;
        };
    });

When I run my program it does not respond to any mouse click. How can I resolve this?

Thank you!