mardi 30 juin 2015

knockout - computed observable with parameter working only on alternate clicks

I have a main checkbox, clicking on which all the checkboxes are checked. For the child checkboxes, I have some different logic involving their computation from 2 different observables besides the mainCheckBox and when child checkboxes are checked, the value needs to be written to different observables.

I have created a computed observable with parameter as below:

var vm = ko.mapping.fromJS(data);
var viewModel = 
function () 
{
    this.self = this;
    this.ExportSchemas = vm;
    this.SelectAll = ko.observable(true);
    this.IsChecked = function (checkboxVM) {
        return ko.computed({
            read: function () {
                return this.SelectAll(); //problemLine
            },
            write: function (value) {
                checkboxVM.Selected(value);
                alert(checkboxVM.Selected());
            },
            owner: this.self
        });
    };
};

<input type="checkbox" data-bind="checked: SelectAll" value="None" id="mainCheckBox" name="check" />

<div data-bind="foreach: ExportSchemas">
    <div data-bind="foreach: Clauses">
        <input type="checkbox" value="None" data-bind="checked: $root.IsChecked($data), attr: { id: 'clause' + Id(), value: Id() }" name="check" />
    </div>
</div>

The write behavior of computed observable is weird, it works on alternate clicks when the problemLine in above code is as written above. And when I use the following instead for problemLine:

return this.SelectAll;

Then the write of computed observable works properly, but the the read stops working and checking/unchecking mainCheckBox has no effect on child check boxes.

Any suggestions?




How to get a row when checking checkbox in html table

I have a HTML table with a checkbox in one of the columns. I want to know how I could get the row data when the user clicks on the checkbox without javascript or jquery.. Only with php and html .. Is it possible?




Loop through SQL result to activate checkboxes?

I have an AjaxModalPopup that displays a list of Checkboxes (18 altogether) that represent options in my main form.

The options are stored in SQL along with the stock code they apply to, in a very simple two column table. [StockCode][Category]

I can save these options to a SQL table correctly and can verify in SQL that they are there.

What I am trying to do is retrieve them with a stored procedure and use the result to check the relevant checkboxes when the modalpopup 'pops' up. I have double checked my procedure in SQL Server Manager and it works fine, but my checkboxes won't select at all.

I would like to end up with a function that pre-selects the checkboxes so when somebody uses the feature to edit the options they don't have to try to remember what is already selected.

Code, VB.NET

Protected Sub btnEditPC_Click(sender As Object, e As System.EventArgs) Handles btnEditPC.Click
    Dim dt As DataTable = SqlHelper.ExecuteDataset(System.Configuration.ConfigurationManager.AppSettings("dbConn"), "xw_GetAllFromPCBuilderCategory", "SY02053").Tables(0)

    For Each row As DataRow In dt.Rows
        For Each item As ListItem In chklstCat.Items
            If String.Equals(row("Category"), item.Text) Then
                item.Selected = True
            End If
        Next
    Next
End Sub

My loop doesn't seem to do anything, but I can't figure out where I've gone wrong. It looks to me as though this should check each result from the data table and compare it to the text value in my checkboxes, then marking the matches?




yii2 gridview set checkboxcolumn checked

I need to assign machines to a machine group (m:n). The mount of machines makes it necesary to use a gridview with checkboxcolumn to assign machines to a group. I got it to work that the relations are getting saved but I didn't figured it out how to make allready assigned machines to be checked in the gridview when it gets loaded. The content of my gridview is a dataprovider based on a MySQL-View. With

 'checkboxOptions' => function($model, $key, $index, $column) {
     return ['checked' => true];
 }

it's possible to check all the checkboxes. But when I'm trying to do this

 'checkboxOptions' => function($model, $key, $index, $column) {
     $bool = in_array($model->id_machine, common\models\MachineGroup::getAssignedMachines());
     return ['checked' => $bool];
 }

an error is thrown: "Cannot use object of type yii\web\View as array". Actually I don't understand what's the problem here but I couldn't find a way to pass the array of the allready selected machines to this funtion (and I tried a lot). When I define a dummy-array manually in the function everything works fine. Need some help here...thanks!




using the checkbox value from a jquery DataTable in laravel eloquent

I have a jQuery DataTable in a Laravel App. I want to confirm the previously stored data from someone else by using a checkbox. When that checkbox is checked I want to update that record's attribute is_confirmed with the value 1 (true). Now I can get all the records that i need to confirm from the database. However when I try to confirm one of them, every single record is confirmed even why i leave the other checkbox unchecked.

I guess that the error is in the controller update method below:

public function update(Request $request)
{
    $user = Auth::user();
    $is_validated = $request->get('is_validated');

    foreach ($is_validated as $valid_Id) {
        if($valid_Id.value(1)) //<-here i suspect that the error is
    {
            DB::table('reports')->update(['is_validated' => 1, 'validated_by' => $user->id]);
        }
    }
    return view('validate.update');
}

I tried changing the value of the checkbox with the code below.

$('.checkbox').change(function(){
    cb = $(this);
    cb.val(cb.prop('checked'));
    cb.value = 1;
});

And I also tried using radio buttons, however since they all have the same name i could only select 1 button in all the records.

I'm stuck at this point and it seems that I can't figure it out on my own. All the help or hints are appreciated.




Add a simple field to django form without updating the model

Django newbie here

I want to add a checkbox to django form, but this checkbox doesn't have to be stored in the database.

A trivial solution is to add it directly to the html template. But I want to keep the django format :

{{ form.as_p }}

So I thought that I need to add the checkbox in the form class.

I did the following :

    class MyForm(forms.ModelForm):
          ...
          check_box = forms.BooleanField(widget=forms.CheckboxInput)

But on the template I can't find the checkbox. Any idea ? Thanks




Drupal Customized Editable View

This one's a doozy. I'm working on a project where we want to be able to create a record, select a group of users and send an email to them directly from Drupal. I'm having trouble figuring out how to do this.

First, I want to be able to create a new record and populate a few fields. So this would be a custom content type or entity. Let's say I'm calling it EMAIL NODE. Here I'd set the title, the email subject and body. The catch is I want to see a table of all the registered users with some fields such as first name, last name, email address, company, etc. It has to be sortable and filterable. Normally I'd use a view to achieve this. I guess an embedded view using hook_form_alter to get it in the edit form.

The catch is that each user row also needs to have a few checkboxes such as Opt In, Opt Out, and Viewed. I need to able to update these checkboxes so that I can manually change any of their states. I also need to be able to select one or more rows then click a button to send them an email. The values of each checkbox should be retained in the EMAIL NODE record.

I can't think of any way to do this using off the shelf modules. I know there's an editable view module, but that assumes I'm editing existing records. In my case all the user's exist, but the state of each checkbox doesn't exist until I create the EMAIL NODE.

I think the only way to do it is a custom module that leverages hook_form_alter to insert the view and uses some javascript to save the state of each checkbox. Maybe use some hidden fields and comma separated UIDs to store the states of each checkbox. When the page loads it parses the fields and based on the UID modifies the state of the checkboxes.

Is there an easier way or is this just a very customized scenario?

Thanks, Howie




Background images in checkbox don't work well

I'm fairly new to android, and I'm making an app with several checkbox. and I have a problem in the design. In some phones (like the Moto G or Sony Ericsson m2) works perfect, but small cell (like Xperia X8 or S Galaxy Mini) it looks bad. The words appear incomplete, I do not understand why? This is the basic code:

<ScrollView
    android:id="@+id/mainScrollView"
    android:layout_width="match_parent"
    android:layout_height="fill_parent"
    android:scrollbarThumbVertical="@drawable/custom_scroll_style"
    android:fillViewport = "true"
    >


    <LinearLayout
        android:orientation="vertical"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:id="@+id/idSecundario"
        android:layout_marginLeft="10dp"
        android:layout_marginRight="10dp"
        >

        <CheckBox
            android:id="@+id/actuarioAdm0"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:onClick="itemClicked"
            android:fontFamily="Arial"
            android:text="@string/ch_analisis_matematico_I"
            android:background="@drawable/amarillo"
            android:button="@drawable/check"
            android:enabled="true"
            />

...

I tried changing the size of the images but still does not work. Someone would know what can happen?

Screenshots:

It looks good (large cell)

Large cell

It does not look good. The words appear incomplete

Small cell

I'm testing. It seems it's relative with background images, but I tried to resize and still not working.

Testing

I'll be very grateful if someone can help me. (Sorry if my English is not well)




Triggering "click" event on a checkbox or radio button toggles the "checked" property after the event handler function finish

Strange behave on jquery click event over radioButton and checkbox

when a user click on a radio button, the property check is toggle first and then the event handler is run.

when the code trigger click event on those elements, first the event handler is running and then the check property is changing.

example here: http://ift.tt/1IqqWAr

 <body >
  <input type="radio" id="test-checkbox" name="test" checked="true"/>
      <input type="radio" id="test-checkbox2" name="test"/>
  <span id="test-click">trigger click event</span>
 </body>

$(function(){


    $("#test-click").click(function(){

        $("#test-checkbox2").click();

    });

    $(document).on("click",'[name$="test"]',function () { 

        print();

    });
    var print=function(){
    alert( $('input[name$="test"]:checked').attr("id"));

    };
});

how can I avoid this problem and trigger the click after the property check is toggle?




Gridx/Grid DOJO : issue with checkbox and filter : when filter is used, checkboxes get uncheked

I am using gridx/grid to make grid where for checkboxes, "IndirectSelect and ExtendedSelect" are used. The issue is, ****when I select some checkboxes and then type something in filter, all checked checkboxes become unchecked****.

Please help in any way the checkboxes checked state can be maintained when filter is used.

Please help. Thanks in Advance.

Following is the code to create grid:

this.grid=new Grid({ id: 'grid', cacheClass: Cache, store: this.store, structure: this.layout, vScrollerBuffSize: 300, selectRowTriggerOnCell: true, barTop: [ DropDownPager, {pluginClass: QuickFilter, style: 'text-align: right;'} ], barBottom: [ LinkSizer, {pluginClass: Summary, style:'text-align:center'}, {pluginClass: LinkPager, style: 'text-align: right;'} ], modules: [ extendedSelect, RowHeader, IndirectSelect, CellWidget, ColumnResizer, Bar, VirtualVScroller, {
moduleClass: Pagination, initialPageSize:10 }, Filter, FilterBar ], autoHeight: false }, document.createElement('div'));




jquery double counts checked boxes

My code is meant to get all of the checkboxes with name attribute "repo_checkbox" and show an alert with the value of each one that is checked. The problem that I am having is that checkboxes with the checked attribute are getting double counted by jquery and popping up once if they get unchecked and twice if they are left checked.

This is the jquery that gets the checked checkboxes

$(document).ready(function(){
    $('#filter_repos').on('click', function(e){
        $("input:checkbox[name='repo_checkbox']").each(function() {
            if ($(this).is(':checked')) 
            {
                alert(this.value);
            }
        });
    });
});

These are the input tags

<input type="checkbox" name="repo_checkbox" value="5" checked=true>5<br>
<input type="checkbox" name="repo_checkbox" value="6" checked=true>6<br>
<input type="checkbox" name="repo_checkbox" value="7">7<br>
<input type="checkbox" name="repo_checkbox" value="8">8<br>
<input type="submit" value="Filter Repos" id="filter_repos">

The ones without "checked=true" work fine, but the ones with it are counted once more than they should be by jquery.




has many through checkboxes?

I have a many-many relationship with students and organizations. When creating a new student, I want to have a checkbox to select one or more organizations and save that. How do I do this? What does the MVC look like specifically? I can't find any online resource that gives me the whole overview.




Show group of checkboxes if a checkbox in the group is checked

Please have a look at the fiddle here.

What I'd like to do is show the checkboxes in the group on page load if any checkbox in the group is prechecked.

here is the HTML:

<ul>
<li class="header">
    <h3>Group 1</h3>
</li>
<li class="option">
    <label><input type="checkbox" /> Value</label>
</li>
<li class="option">
    <label><input type="checkbox" checked="checked" /> Value</label>
</li>
<li class="option">
    <label><input type="checkbox" /> Value</label>
</li>
<li class="header">
    <h3>Group 2</h3>
</li>
<li class="option">
    <label><input type="checkbox" /> Value</label>
</li>
<li class="option">
    <label><input type="checkbox" /> Value</label>
</li>
<li class="option">
    <label><input type="checkbox" /> Value</label>
</li>
<li class="header">
    <h3>Group 3</h3>
</li>
<li class="option">
    <label><input type="checkbox" /> Value</label>
</li>
<li class="option">
    <label><input type="checkbox" /> Value</label>
</li>
<li class="option">
    <label><input type="checkbox" /> Value</label>
</li>
</ul>

The main obstacle for me is I can't wrap the group (like in a <div> or an <li>) because the headers are inserted dynamically. It would be great to show/hide the wrap, but that's not an option. I can't figure out how to target the checkboxes in the group if I can't wrap it. Your ideas are greatly appreciated.




Increase value of element based on checkbox status

I can't seem to figure out a way of increasing value of SPAN based on checkboxes checked. For example I have 3 checkboxes

    <input type="checkbox" class="cbox" id ="one"/>One
    <input type="checkbox" class="cbox" id="two"/>Two
    <input type="checkbox" class="cbox" id="three"/>Three
<span id="increment-me">10</span>

And I need to figure out a way of increasing value in real time by X amount based on checkboxes clicked. For example by 5 if #one is checked,and by 7 more if #two is checked etc.




JFace: Disable some checkboxes in TableViewer

I created jface TableViewer with a style SWT.CHECK. I need to disable checkboxes in some rows of the table. I know how to make they will not change their states but I haven't any idea, how to change their look. I need them to be grayed but not like it does the method setGrayed which make them filled with color. I need user to know immediately that the checkboxes are not editable.

I read SWT/JFace: disabled checkbox in a table column but there is not answer I'm looking for. It has been a few years ago, so perhaps it is now some way to do it.




Checkbox status not being passed when dialog button pressed

I'm trying to implement a check box in a MaterialDialog using this library, and the check box asks the user if they don't want to see that dialog again. The dialog appears if the user's phone has NFC, but it is deactivated.

If the user presses the positive button in the dialog and has the box ticked, then it accesses a Realm object with a Boolean attribute named "NfcStatus", and sets that to true. If they press the negative button with the box ticked, then that Realm object's NfcStatus is set to false.

Here's the code of the MaterialDialog:

new MaterialDialog.Builder(context)
            .title("NFC")
            .content("NFC is disabled. Would you like to activate it?")
            .items(R.array.checkbox) //this just has one string in it which says "Please don't show me this again"
            .itemsCallbackMultiChoice(null, new MaterialDialog.ListCallbackMultiChoice() {
                @Override
                public boolean onSelection(MaterialDialog dialog, Integer[] which, CharSequence[] text) {
                    /**
                     * If you use alwaysCallMultiChoiceCallback(), which is discussed below,
                     * returning false here won't allow the newly selected check box to actually be selected.
                     * See the limited multi choice dialog example in the sample project for details.
                     **/
                    checkboxIsChecked = true; //TODO: checkboxIsChecked isn't being passed into onPositive or onNegative
                    return true;
                }
            })
            .positiveText(R.string.accept)
            .positiveColorRes(R.color.main_theme_color)
            .negativeText(R.string.decline)
            .negativeColorRes(R.color.main_theme_color)
            .callback(new MaterialDialog.ButtonCallback() {
                @Override
                public void onPositive(MaterialDialog dialog) {
                    //this was how I was checking if checkboxIsChecked was true or false
                    Log.d("checkboxIsChecked", checkboxIsChecked?"true":"false"); }

                    if (checkboxIsChecked) {begins
                        if (ks.contains(KEY_NAME)) {
                            realmKey = ks.get(KEY_NAME);
                        }
                        realm = Realm.getInstance(context, realmKey);
                        RealmPhone realmPhone = realm.where(RealmPhone.class).findFirst();                      realmPhone.setNfcStatus(true);                          
                    }
                    activity.finish();
                    startNfcSettingsActivity();

                    Toast.makeText(context, R.string.nfc_disabled_message, Toast.LENGTH_LONG).show();
                }

                @Override
                public void onNegative(MaterialDialog dialog) {
                    if (checkboxIsChecked) {
                        if (ks.contains(KEY_NAME)) {
                            realmKey = ks.get(KEY_NAME);
                        }
                        realm = Realm.getInstance(context, realmKey);
                        RealmPhone realmPhone = realm.where(RealmPhone.class).findFirst();
                        realmPhone.setNfcStatus(false);

                    }
                }

            })
            .cancelable(false)
            .show();

The problem was that even if the check box was ticked, the checkboxIsChecked variable was still false when using it in onPositive or onNegative, so it was never being written to the Realm object. Am I doing this the wrong way?




checkboxGroupInput - set minimum and maximum number of selections - ticks

Here is example code with check-box group input:

library(shiny)

server <- function(input, output) {
  output$Selected <- renderText({
    paste(input$SelecetedVars,collapse=",")
  })
}

ui <- fluidPage(
  sidebarLayout(
    sidebarPanel(
      checkboxGroupInput("SelecetedVars", "MyList:",
                         paste0("a",1:5), selected = "a1")
    ),
    mainPanel(textOutput("Selected"))
  )
)

shinyApp(ui = ui, server = server)

enter image description here

As you you can see from image above we can select as many as we want, in this case 4 out of 5.

How can I set minimum and maximum number of ticks? I need minimum of 1 option checked and maximum of 3 options checked. i.e.: prevent unticking the last tick, and prevent ticking when 3 options were already ticked.




How can I check if this check box is enabled from another method in Java?

What I am trying to do is check if a check box is enabled from another method that is also running on another thread. I am fairly new to Java so I apologise in advanced if my code isn't how Java is usually written (or if it is written badly).

So I've made a method that created a iframe then adds a check box to it. I've removed the part which creates the jframe just to keep my code minimal - you can see it below:

private void initialize() {
    chckbxEnabled.setHorizontalAlignment(SwingConstants.LEFT);
    chckbxEnabled.setForeground(Color.WHITE);
    chckbxEnabled.setBounds(98, 123, 81, 23);
    frame.getContentPane().add(chckbxEnabled);
}

I've then created a new method in a new thread and called it from another method which I haven't shown here.

static Thread thread = new Thread(new Runnable() {
public void getPing() throws IOException, InterruptedException {
    while (true) {
        System.out.println(chckbxEnabled.isEnabled());
        if(chckbxEnabled.isEnabled()) {] // Part I am having trouble with
            String apiKey = "exmapleApiKey";
            URL url = new URL("http://ift.tt/1C4JzZI"+apiKey);
            URLConnection yc = url.openConnection();
            BufferedReader in = new BufferedReader(
                                    new InputStreamReader(
                                    yc.getInputStream()));
            String inputLine;
            inputLine = in.readLine();
            }
        Thread.sleep(1000);
    }
}
   public void run() {     
       try {
            getPing();
        } catch (IOException e) {
            e.printStackTrace();
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
       }
    });
}

As you can see I am trying to access chckbxEnabled.isEnabled(). This worked because just after I made my main class I added private static JCheckBox chckbxEnabled = new JCheckBox("Enabled");. So I can access it but it always returns true when I print it even though the check box is sometimes checked.

So my question is what is a better way of doing this as I expect that way I have experimented with is 'messy' and not the way it should be done?




Django crispy forms: add text next to a checkbox?

It seems to be simple but I can't figure out how to add some text next to my checkbox. I don't want to override the template (I think I don't need to). For now, I have a checkbox that works, but how to put some text like "I Agree TOS" at the right of the checkbox?

Here is what I have: http://ift.tt/1JnAniM

class TenantSignupForm(forms.Form):
    email = forms.EmailField()
    password = forms.CharField(
        widget=forms.PasswordInput(),
        validators=[RegexValidator(regex=r'[A-Za-z0-9@#$%^&+=]{8,}', code=None),
                    MaxLengthValidator(32)])
    password_confirmation = forms.CharField(
        widget=forms.PasswordInput())
    agree_tos = forms.BooleanField()

    def __init__(self, *args, **kwargs):
        super(TenantSignupForm, self).__init__(*args, **kwargs)
        self.helper = unvariable_helper(self)
        self.helper.form_class = 'm-t'
        self.helper.form_action = 'signup'
        self.helper.layout = Layout(
            Field('email', placeholder="Email"),
            Field('password', placeholder="Password"),
            Field('password_confirmation', placeholder="Confirm your password"),
            Field('agree_tos', wrapper_class='i-checks'),
            FormActions(
                Submit('signup',
                       'Register',
                       css_class='btn btn-primary block full-width m-b'
                      )
                )
        )




Only sending mail to one of the ticked checkboxes

Ce résumé n'est pas disponible. Veuillez cliquer ici pour afficher l'article.


lundi 29 juin 2015

removing values of unchecked checkboxes

hi guys, I am having following code to generate a checkbox dynamically and get its value in the variable. The main problem faced by me is that I do not know how to remove the value from the variable once the checkbox is unchecked.

thanks I advance...

function getCheckBox(contentItem) {
        var checkbox = $("<input type='checkbox'/>");
        checkbox.css("height", "20");
        checkbox.css("width", "20");

        checkbox.change(function () {
            var checked = checkbox[0].checked;

            $(':checkbox').change(function () {
                if ($(this).is(':checked'))
                {
                    contentItem.value.details.checked = true;
                    global_audit_team = global_audit_team + contentItem.value.Name + ",";
                    alert(global_audit_team);
                }

                else
                {
                    contentItem.value.details.checked = false;
                    alert(contentItem.value.Name + " unchecked");
                }
            });


        });
        return checkbox;
    };




How to avoid triggering the fast-scroller when a checkbox in the list-row is being clicked?

Background

Suppose I have a ListView with a checkbox for each row , and I have a lot of items to show so the fast-scroller should be enabled.

The problem

when clicking on a checkbox, if it's too near the right edge of the ListView, it will trigger the fast-scroller and also scroll using it, instead of toggling the checkbox.

Code

Here's a sample code:

MainActivity.java

public class MainActivity extends AppCompatActivity
  {

  @Override
  protected void onCreate(Bundle savedInstanceState)
    {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    ListView listView=(ListView)findViewById(android.R.id.list);
    String[] items=new String[200];
    for(int i=0;i<items.length;i++)
      items[i]="item "+i;
    ArrayAdapter<String> itemsAdapter=
            new ArrayAdapter<String>(this,R.layout.list_item,android.R.id.text1,items);

    listView.setAdapter(itemsAdapter);
    }
  }

list_item.xml

<LinearLayout
  xmlns:android="http://ift.tt/nIICcg"
  xmlns:tools="http://ift.tt/LrGmb4"
  android:layout_width="match_parent"
  android:layout_height="wrap_content"
  android:orientation="horizontal"
  android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
  android:paddingLeft="?attr/listPreferredItemPaddingLeft"
  android:paddingRight="?attr/listPreferredItemPaddingRight"
  android:paddingStart="?android:attr/listPreferredItemPaddingStart"
  tools:context=".MainActivity">

  <TextView
    android:id="@android:id/text1"
    android:layout_width="0px"
    android:layout_height="wrap_content"
    android:layout_weight="1"/>

  <CheckBox
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"/>

</LinearLayout>

activity_main.xml

<LinearLayout
  xmlns:android="http://ift.tt/nIICcg"
  xmlns:tools="http://ift.tt/LrGmb4"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  android:orientation="vertical"
  tools:context=".MainActivity">

  <ListView
    android:id="@android:id/list"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fastScrollEnabled="true"/>
</LinearLayout>

The question

How can I avoid this, and let the checbox being checked instead of triggering the scrolling using the fast-scroller?




Rails 4 checkbox validation when checked still asks user to check it

I'm adding a checkbox to a sign up page that requires a user check a box agreeing to terms of use. Checking the box is supposed to be required to sign up.

The problem is that when the box is checked and submit is clicked, the message says user must check the box. As a result user can't sign up.

So it looks like there is 2 ways to do the checkbox for terms of service - with and without a distinct db column. I went the db column route which is probably harder but I already had done that part.

This is what I know ... I can see terms_accepted is now in the users table as a boolean. All previous users terms_accepted marked FALSE which makes sense.

I've read lots of comments online about this, and tried about 10 flavors of the validation snippet without luck. It may have something about Rails 4 that I'm missing. What I read online says if you do have a db column for this, DO use an accept option. If you do have a db column DO NOT use the validates_acceptance_of in your user.rb.

I followed the Ruby doc for validations in section 2.1 says to do it like this:

class Person < ActiveRecord::Base
  validates :terms_of_service, acceptance: { accept: 'yes' }
end

This is my user controller and model:

class UsersController < ApplicationController
  before_filter :authenticate_user!
  before_filter :admin_only, :except => :show

  def index
    @users = User.all
  end

  def show
    @user = User.find(params[:id])
    unless current_user.admin?
      unless @user == current_user
        redirect_to :back, :alert => "Access denied."
      end
    end
  end

  def update
    @user = User.find(params[:id])
    if @user.update_attributes(secure_params)
      redirect_to users_path, :notice => "User updated."
    else
      redirect_to users_path, :alert => "Unable to update user."
    end
  end

  def destroy
    user = User.find(params[:id])
    user.destroy
    redirect_to users_path, :notice => "User deleted."
  end

  private

  def user_params
    params.require(:user).permit(:name, :email, :terms_accepted)
  end

  def admin_only
    unless current_user.admin?
      redirect_to :back, :alert => "Access denied."
    end
  end

  def secure_params
    params.require(:user).permit(:role)
  end
end

---
class User < ActiveRecord::Base
  validates :terms_accepted, acceptance: { accept: 'yes' }

  enum role: [:user, :vip, :admin]
  after_initialize :set_default_role, :if => :new_record?


  def set_default_role
    self.role ||= :user
  end

  # Include default devise modules. Others available are:
  # :confirmable, :lockable, :timeoutable and :omniauthable
  devise :invitable, :database_authenticatable, :registerable, :confirmable,
         :recoverable, :rememberable, :trackable, :validatable
  end
---

Here is the views/devise/registrations/new (View for Sign Up form)

<div class="row">
  <div class="col-md-6">
    <%= form_for(resource, :as => resource_name, :url =>     registration_path(resource_name), :html => { :role => 'form'}) do |f| %>
        <h2 class="form-signin-heading">Sign Up</h2>
        <%= devise_error_messages! %>
        <div class="form-group">
          <%= f.label :name %>
          <%= f.text_field :name, :autofocus => true, class: 'form-control' %>
        </div>
        <div class="form-group">
          <%= f.label :email %>
          <%= f.email_field :email, class: 'form-control' %>
        </div>
        <div class="form-group">
          <%= f.label :password %>
          <%= f.password_field :password, class: 'form-control' %>
        </div>
            <div class="form-group">
          <%= f.label :confirm_password %>
          <%= f.password_field :password_confirmation, class: 'form-control' %>
        </div>
        <div class="form-group">
          <%= f.check_box :terms_accepted%>
          <%= f.label :accept_terms %>
          <%= link_to 'Terms Of Use', '/TermsOfUse.html', :target => "_blank" %>
        </div>
        <div class="form-group">
          <%= f.submit 'Sign Up', :class => 'btn btn-lg btn-login' %>
        </div>
        <div class="form-group">
          <%= render "devise/shared/links" %>
        </div>
    <% end %> 
 </div>

Output:

Started GET "/" for ::1 at 2015-06-29 13:55:55 -0700 Processing by VisitorsController#index as HTML (0.5ms) SELECT COUNT(*) FROM "users" Rendered visitors/index.html.erb within layouts/application (1.6ms) Rendered layouts/_flatlabnavbartop.html.haml (16.2ms) Completed 200 OK in 347ms (Views: 345.7ms | ActiveRecord: 0.5ms)

Started GET "/users/sign_up" for ::1 at 2015-06-29 13:56:00 -0700 Processing by DeviseInvitable::RegistrationsController#new as HTML Rendered /usr/local/rvm/gems/ruby-2.2.1@suits6/gems/devise-3.4.1/app/views/devise/shared/_links.html.erb (1.4ms) Rendered devise/registrations/new.html.erb within layouts/application (51.9ms) Rendered layouts/_flatlabnavbartop.html.haml (1.9ms) Completed 200 OK in 279ms (Views: 277.9ms | ActiveRecord: 0.0ms)

Started POST "/users" for ::1 at 2015-06-29 13:56:29 -0700 Processing by DeviseInvitable::RegistrationsController#create as HTML Parameters: {"utf8"=>"✓", "authenticity_token"=>"4t0UPaQhI/0HcsqC3RkBrcWQWjhWzKojZLvrMloObPSAiapVc46bvxT5TGePh4v2IUCi8QbdVuMWuQsyzyFmdg==", "user"=>{"name"=>"Maude Username", "email"=>"maude@gmail.com", "password"=>"[FILTERED]", "password_confirmation"=>"[FILTERED]", "terms_accepted"=>"1"}, "commit"=>"Sign Up"}

Unpermitted parameter: terms_accepted

User Load (119.8ms) SELECT "users".* FROM "users" WHERE "users"."email" = $1 AND "users"."encrypted_password" = $2 ORDER BY "users"."id" ASC LIMIT 1 [["email", "maude@gmail.com"], ["encrypted_password", ""]]

(0.2ms) BEGIN User Exists (16.6ms) SELECT 1 AS one FROM "users" WHERE "users"."email" = 'maude@gmail.com' LIMIT 1

(8.3ms) ROLLBACK Rendered /usr/local/rvm/gems/ruby-2.2.1@suits6/gems/devise-3.4.1/app/views/devise/shared/_links.html.erb (0.7ms)

Rendered devise/registrations/new.html.erb within layouts/application (18.5ms)

Rendered layouts/_flatlabnavbartop.html.haml (2.9ms)

Completed 200 OK in 733ms (Views: 383.5ms | ActiveRecord: 144.9ms)


TL;DR: It is doing a rollback and saying unpermitted parameters for terms_aacpeted is stopping it. But for sure I have those in the user_params in the UsersController.

What needs to be changed?




Quick way to see if all checkboxes are unselected

I have a java JPanel with 16 JCheckBoxes and I am wanting to ensure that the user selects at least one before submitting the form. The only way I know to do this is a huge if statement that looks at the Boolean value of the "isSelected()" method, but this seems inefficient. So I was wondering if there was a faster to way to check if all of the boxes are unchecked.




jquery double counts my checkboxes

I'm trying to get all of the checked checkboxes on my page using jquery, but it appears that jquery is counting boxes with the checked="checked" attribute as well as boxes that actually appear to be checked.

I am using the following code to retrieve the checked boxes: $("input:checkbox[name='repo_filter']:checked");

With the checkboxes getting generated like this:
<input type="checkbox" name="repo_filter" checked="checked">

It returns that there is a checkbox checked if the box originally had the checked attribute even if it was since unchecked.

Any help is much appreciated.




create CheckBox on button press

i am trying to create a checkbox, when a button is clicked, but i always get this error:

Error:(30, 52) error: incompatible types: <anonymous OnClickListener> cannot be converted to Context

this is how i am trying it

protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    Button myButton = (Button) findViewById(R.id.myButton);

    myButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {

            LinearLayout myLayout = (LinearLayout) findViewById(R.id.myLayout);

            CheckBox myCheckBox = new CheckBox(this);
            myCheckBox.setLayoutParams(new LinearLayout.LayoutParams(
                    LinearLayout.LayoutParams.FILL_PARENT,
                    LinearLayout.LayoutParams.FILL_PARENT));

            myLayout.addView(myCheckBox);
        }
    });

}

please help! thanks




Inconsistent display of checkboxes on PDF form filled with PDFtk

I am filling PDF forms in my rails app with the pdf-forms (http://ift.tt/1qvTScH) gem, based on PDFtk. Text fields work as I would expect, but my checkbox fields do not. The boxes display well in Chrome, but in Preview and Mail the checkbox fields appear empty.

class FormsController < ApplicationController
require 'pdf_forms'
def acord25
  @policy = Policy.find(params[:id])
  pdftk = PdfForms.new('/usr/local/bin/pdftk')
  # find out the field names that are present in form.pdf
  pdftk.get_field_names 'lib/pdfs/acord25.pdf'

  # take form.pdf, set the 'foo' field to 'bar' and save the document to myform.pdf
  pdftk.fill_form '/lib/pdfs/acord25.pdf', "acord25.pdf", 
     "F[0].P1[0].Form_CompletionDate_A[0]" => @policy.dateIssued,
     "F[0].P1[0].Producer_FullName_A[0]" => @policy.client.broker.name,
     "F[0].P1[0].Producer_MailingAddress_LineOne_A[0]" => @policy.client.broker.company,
     "F[0].P1[0].Producer_MailingAddress_LineTwo_A[0]" => @policy.client.broker.address,
     "F[0].P1[0].Producer_ContactPerson_FullName_A[0]" => @policy.legalVesting,
     "F[0].P1[0].Producer_ContactPerson_PhoneNumber_A[0]" => @policy.client.broker.phone,
     "F[0].P1[0].Producer_FaxNumber_A[0]" => @policy.client.broker.fax,
     "F[0].P1[0].Producer_ContactPerson_EmailAddress_A[0]" => @policy.client.broker.email,
     "F[0].P1[0].NamedInsured_FullName_A[0]" => @policy.client.name,
     "F[0].P1[0].NamedInsured_MailingAddress_LineOne_A[0]" => @policy.client.address.titlecase,
     "F[0].P1[0].GeneralLiability_CoverageIndicator_A[0]" => 1,
     "F[0].P1[0].GeneralLiability_OccurrenceIndicator_A[0]" => 1,
     "F[0].P1[0].GeneralLiability_GeneralAggregate_LimitAppliesPerLocationIndicator_A[0]" => 1,
     "F[0].P1[0].Policy_PolicyNumberIdentifier_A[0]" => @policy.policyNumber,
     "F[0].P1[0].Policy_EffectiveDate_A[0]" => @policy.dateEffective,
     "F[0].P1[0].PolicyExpirationGeneral[0]" => @policy.term.dayEnd,
     "F[0].P1[0].Insurer_FullName_A[0]" => "Lexington Insurance Company",
     "F[0].P1[0].Insurer_NAICCode_A[0]" => 19437,
     "F[0].P1[0].Insurer_FullName_B[0]" => "Commerce & Industry Insurance Company",
     "F[0].P1[0].Insurer_NAICCode_B[0]" => 19410,
     "F[0].P1[0].Insurer_FullName_C[0]" => "Great American Insurance Company",
     "F[0].P1[0].Insurer_NAICCode_C[0]" => 37532,
     "F[0].P1[0].Insurer_FullName_D[0]" => "Admiral Insurance Company",
     "F[0].P1[0].Insurer_NAICCode_D[0]" => 24856,
     "F[0].P1[0].GeneralLiability_InsurerLetterCode_A[0]" => "A",
     "F[0].P1[0].GeneralLiability_EachOccurrence_LimitAmount_A[0]" => 1000000,
     "F[0].P1[0].GeneralLiability_FireDamageRentedPremises_EachOccurrenceLimitAmount_A[0]" => 50000,
     "F[0].P1[0].GeneralLiability_MedicalExpense_EachPersonLimitAmount_A[0]" => "Excluded",
     "F[0].P1[0].GeneralLiability_PersonalAndAdvertisingInjury_LimitAmount_A[0]" => 1000000,
     "F[0].P1[0].GeneralLiability_GeneralAggregate_LimitAmount_A[0]" => 2000000,
     "F[0].P1[0].GeneralLiability_ProductsAndCompletedOperations_AggregateLimitAmount_A[0]" => 2000000,
     "F[0].P1[0].Vehicle_InsurerLetterCode_A[0]" => "A",
     "F[0].P1[0].Vehicle_HiredAutosIndicator_A[0]" => 1,
     "F[0].P1[0].Vehicle_NonOwnedAutosIndicator_A[0]" => 1,
     "F[0].P1[0].Policy_PolicyNumberIdentifier_B[0]" => @policy.policyNumber,
     "F[0].P1[0].Policy_EffectiveDate_B[0]" => @policy.dateEffective,
     "F[0].P1[0].Policy_ExpirationDate_B[0]" => @policy.term.dayEnd,
     "F[0].P1[0].Vehicle_CombinedSingleLimit_EachAccidentAmount_A[0]" => 1000000,
     "F[0].P1[0].ExcessUmbrella_InsurerLetterCode_A[0]" => "B",
     "F[0].P1[0].ExcessUmbrella_OccurrenceIndicator_A[0]" => 1,
     "F[0].P1[0].ExcessUmbrella_DeductibleIndicator_A[0]" => 1,
     "F[0].P1[0].ExcessUmbrella_Umbrella_DeductibleOrRetentionAmount_A[0]" => @policy.coverages.first.deductibleOcc,
     "F[0].P1[0].Policy_PolicyNumberIdentifier_D[0]" => @policy.policyNumber,
     "F[0].P1[0].Policy_EffectiveDate_D[0]" => @policy.dateEffective,
     "F[0].P1[0].Policy_ExpirationDate_D[0]" => @policy.term.dayEnd,
     "F[0].P1[0].ExcessUmbrella_Umbrella_EachOccurrenceAmount_A[0]" => 10000000,
     "F[0].P1[0].ExcessUmbrella_Umbrella_AggregateAmount_A[0]" => 10000000

     send_file("#{Rails.root}/acord25.pdf", filename: "#{@policy.client.name} - #{@policy.carrier.name} - #{@policy.policyNumber} (#{Time.now}).pdf", type: "application/vnd.ms-excel")
end
end

TL;DR: Checked boxes display in Chrome, but not in Preview or Mail.

I appreciate any help or leads on what the problem might be. Thank you!




HTML5 Browser Validation for Checkboxes - given multiple checkboxes how can I make sure at-least one is selected?

Given something simple like this:

<form ...>
<input type="checkbox" required name="op1"> Option 1</u>
<input type="checkbox" required name="op2"> Option 2</u>
<input type="submit">
</form>

Is there any way using HTML5 Validation to validate if one of the boxes are checked and if none are selected to focus the required tooltip on the form?




How can I group a checkbox element with a number type element and work with it in html5?

I am creating an app in django and I have the next problem:

In my html5 template, I have the next structure that represents some kids and the chocolate bars they want to eat.

{% for kid_information in result %}


            <br/><input type="checkbox" name="kid" id="kid" value="{{kid_information.name}}" />
                <label for="kid"><b>{{ kid_information.name }}</b></label>       

            Chocolate-Bars: <input type="number" name="chocbars">  


{% endfor %}
<br/><br/>

As you can see, I have a 'for' structure represent a list of kids that I have, and show their name, and a field to let the user select how many chocolate bars give to each kid. I want it to be a 'checkbox' structure, to let the user select the kids and the number of the chocbars of each kid.

This is inserted in a 'form' stucture, so that when I click on the "submit" button, I treat the selection in the correspondent view.

In my view, I know that if I do the next, I get the list of the selected checkbox items:

selected_kids = request.POST.getlist('kid')
    for selected_current_kid in selected_kids:
     ...

But the problem is that I want to get the selected kids and the specified chocolate bars with each selected kid. How can get it in the view? Is there any way to group the checkbox element "kid" and the "number" field?

Thanks!!!




Using sharedpreferences for saving a lot of checkbox states

I know there is a lot of documentation for using shared preferences but I confused on how to implement it for my case. I have custom action bar for my activities with custom buttons that take you to the previous and next pages. When I navigate via these buttons, I want to be able to save the state of all of my checkboxes. I'm 90% sure I'm doing this wrong and I wonder if there is a better way considering the amount of lines I'm using. This code is in my first activity and when I clicked my custom next button and then previous button to return to it, it's not saving state:

boolean bPrearrival_1, bPrearrival_2, bPrearrival_3, bPrearrival_4, bPrearrival_5,
        bPrearrival_6, bPrearrival_7, bPrearrival_8, bPrearrival_9, bPrearrival_10,
        bPrearrival_11, bPrearrival_12;

@Override
public void onSaveInstanceState(Bundle savedInstanceState) {
    super.onSaveInstanceState(savedInstanceState);
    savedInstanceState.putBoolean("prearrival_1", checkboxList.get(0).isChecked());
    savedInstanceState.putBoolean("prearrival_2", checkboxList.get(1).isChecked());
    savedInstanceState.putBoolean("prearrival_3", checkboxList.get(2).isChecked());
    savedInstanceState.putBoolean("prearrival_4", checkboxList.get(3).isChecked());
    savedInstanceState.putBoolean("prearrival_5", checkboxList.get(4).isChecked());
    savedInstanceState.putBoolean("prearrival_6", checkboxList.get(5).isChecked());
    savedInstanceState.putBoolean("prearrival_7", checkboxList.get(6).isChecked());
    savedInstanceState.putBoolean("prearrival_8", checkboxList.get(7).isChecked());
    savedInstanceState.putBoolean("prearrival_9", checkboxList.get(8).isChecked());
    savedInstanceState.putBoolean("prearrival_10", checkboxList.get(9).isChecked());
    savedInstanceState.putBoolean("prearrival_11", checkboxList.get(10).isChecked());
    savedInstanceState.putBoolean("prearrival_12", checkboxList.get(11).isChecked());
}

@Override
protected void onRestoreInstanceState(Bundle savedInstanceState) {
    super.onRestoreInstanceState(savedInstanceState);
    bPrearrival_1 = savedInstanceState.getBoolean("prearrival_1");
    bPrearrival_2 = savedInstanceState.getBoolean("prearrival_2");
    bPrearrival_3 = savedInstanceState.getBoolean("prearrival_3");
    bPrearrival_4 = savedInstanceState.getBoolean("prearrival_4");
    bPrearrival_5 = savedInstanceState.getBoolean("prearrival_5");
    bPrearrival_6 = savedInstanceState.getBoolean("prearrival_6");
    bPrearrival_7 = savedInstanceState.getBoolean("prearrival_7");
    bPrearrival_8 = savedInstanceState.getBoolean("prearrival_8");
    bPrearrival_9 = savedInstanceState.getBoolean("prearrival_9");
    bPrearrival_10 = savedInstanceState.getBoolean("prearrival_10");
    bPrearrival_11 = savedInstanceState.getBoolean("prearrival_11");
    bPrearrival_12 = savedInstanceState.getBoolean("prearrival_12");
}

@Override
protected void onResume() {
    super.onResume();
    checkboxList.get(0).setChecked(bPrearrival_1);
    checkboxList.get(1).setChecked(bPrearrival_2);
    checkboxList.get(2).setChecked(bPrearrival_3);
    checkboxList.get(3).setChecked(bPrearrival_4);
    checkboxList.get(4).setChecked(bPrearrival_5);
    checkboxList.get(5).setChecked(bPrearrival_6);
    checkboxList.get(6).setChecked(bPrearrival_7);
    checkboxList.get(7).setChecked(bPrearrival_8);
    checkboxList.get(8).setChecked(bPrearrival_9);
    checkboxList.get(9).setChecked(bPrearrival_10);
    checkboxList.get(10).setChecked(bPrearrival_11);
    checkboxList.get(11).setChecked(bPrearrival_12);

}




Appending URL using jQuery based on whether a checkbox is checked

I am trying to append a URL using jQuery.

I have a grid of 'warnings' on my page, populated from a servlet. There is a check box at the top of the screen, which when checked will show the cleared warnings along with the active ones. Basically, this check box is showing and hiding rows of the grid. There's a button to clear a warning, and a button to unclear warnings. The unclear button shows when the checkbox is checked.

Upon first click of the check box, the URL is appended correctly. However, when unchecking the check box, the unclear button sticks and the URL is not properly appended.

Here's my jQuery:

 $(document).ready(function() 
   {
      var showClearedWarningsFlag = getURLParameter("showHideClearedWarnings");

  if(showClearedWarningsFlag = "SHOW")
  {
     $('#showClearedWarningsCheckBox').prop('checked', true);
     $('#unclearButton').show();
  }
  else
  {
     $('#showClearedWarningsCheckBox').prop('checked', false);
     $('#unclearButton').hide();
  }

});


 $('#showClearedWarningsCheckBox').change(function ()
 {
    if($(this).is(':checked'))
    { 
       window.location.search = "?showHideClearedWarnings=" + "SHOW";    
    }
    else
    {
       window.location.search = "?showHideClearedWarnings=" + "HIDE";
    }

 });

$('#clearButton').click(function(){
         $('#bagWarningAction').val('CLEAR') ;
    });

   $('#unclearButton').click(function(){
       $('#bagWarningAction').val('UNCLEAR') ;
   });

So, what I am trying to do here:

if URL is show
   then show unclear button and check box
else if URL is hide
   don't show unclear button and don't check box
on change of checkbox
   if checked
      append URL to show
   else if not checked
      append URL to hide

Then, I have the two buttons for clear and unclear passing through SHOW or HIDE to a hidden input on my page.

However, what is happening is when I press the check box for show cleared warnings, this is successfully appending the URL, but leaves the checkbox unchecked on the page refresh. So, upon checking the checkbox again, it's just redirecting to the SHOW URL. If I manually change the URL to HIDE, it hides the cleared warnings.

I think I am missing something very subtle here. If anyone could shed light as to why the checkbox isn't surviving the refresh, I would be very grateful!




how to bind from comma separated string to checkbox in gridview using asp.net

I have table called Account like this,

ID   Code   X-Ref
1    1.1    NULL
2    1.2    NULL
3    1.3    NULL
...

I have binded Code values to dropdownlist, when i select code value in dropdown the gridview will display rest of the code values(i.e.,Except the one which i have selected in dropdownlist).

I have a checkbox in gridview when i select some of the row and click ok it will update the table with respect to code ID like as shown below,

ID   Code   X-Ref
1    1.1    1.2,1.3
2    1.2    1.1,1.3,1.4
3    1.3    1.2,1.4
...

Now the question is how to populate from database with checkbox enabled in gridview.. example.., if i select 1.1 in drop down list the checkboxes of both row 1.1 and 1.3 should be checked in gridview. How to do that please help..




How to setview in center of a table layout column

I am having a check box with in table layout of five columns and i had placed check boxes in the last column of my table layout but it was not placing at the center of the column can any one tell me how to place check boxes at the center of the column in the table layout in android

This is my xml

<TableLayout
        android:id="@+id/table_layout_manual_mode"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_alignParentLeft="true"
        android:layout_alignParentRight="true"
        android:layout_alignParentTop="true"
         >

        <TableRow
            android:id="@+id/After_connection_heading_one"
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_weight="1"
            android:background="#673AB7" >

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginLeft="10dp"
                android:text="CHECK ON J14"
                android:textColor="#FFFFFF"
                android:textSize="20dp" />
        </TableRow>

        <TableRow
            android:id="@+id/tableRow1_manual"
            android:layout_width="wrap_content"
            android:layout_height="0dp"
            android:layout_weight="1"
            android:gravity="center" >

            <TextView
                android:id="@+id/textView1"
                android:layout_width="0dp"
                android:layout_height="65dp"
                android:layout_weight="0.35"
                android:background="@drawable/cell_shape"
                android:gravity="center"
                android:text="@string/TP_15_Sno"
                android:textAppearance="?android:attr/textAppearanceMedium"
                android:textSize="20dp" />

            <TextView
                android:id="@+id/textView2"
                android:layout_width="0dp"
                android:layout_height="65dp"
                android:layout_weight="1.5"
                android:background="@drawable/cell_shape"
                android:gravity="center"
                android:text="@string/TP_15_Description"
                android:textAppearance="?android:attr/textAppearanceMedium"
                android:textSize="20dp" />

            <TextView
                android:id="@+id/textView3"
                android:layout_width="0dp"
                android:layout_height="65dp"
                android:layout_weight="1"
                android:background="@drawable/cell_shape"
                android:gravity="center"
                android:text="@string/Test_Point_15"
                android:textAppearance="?android:attr/textAppearanceMedium"
                android:textSize="20dp" />

            <TextView
                android:id="@+id/textView4"
                android:layout_width="0dp"
                android:layout_height="65dp"
                android:layout_weight="1"
                android:background="@drawable/cell_shape"
                android:gravity="center"
                android:text="@string/TP_15_Range"
                android:textAppearance="?android:attr/textAppearanceMedium"
                android:textSize="20dp" />

            <CheckBox
                android:id="@+id/cb_1"
                android:layout_width="0dp"
                android:layout_height="65dp"
                android:layout_weight="1"
                android:background="@drawable/cell_shape"
                android:gravity="center"

                />
        </TableRow>

        <TableRow
            android:id="@+id/tableRow2_manual"
            android:layout_width="wrap_content"
            android:layout_height="0dp"
            android:layout_weight="1"
            android:gravity="center" >

            <TextView
                android:layout_width="0dp"
                android:layout_height="65dp"
                android:layout_weight="0.35"
                android:background="@drawable/cell_shape"
                android:gravity="center"
                android:text="@string/TP_16_Sno"
                android:textAppearance="?android:attr/textAppearanceMedium"
                android:textSize="20dp" />

            <TextView
                android:layout_width="0dp"
                android:layout_height="65dp"
                android:layout_weight="1.5"
                android:background="@drawable/cell_shape"
                android:gravity="center"
                android:text="@string/TP_16_Description"
                android:textAppearance="?android:attr/textAppearanceMedium"
                android:textSize="20dp" />

            <TextView
                android:layout_width="0dp"
                android:layout_height="65dp"
                android:layout_weight="1"
                android:background="@drawable/cell_shape"
                android:gravity="center"
                android:text="@string/Test_Point_16"
                android:textAppearance="?android:attr/textAppearanceMedium"
                android:textSize="20dp" />

            <TextView
                android:layout_width="0dp"
                android:layout_height="65dp"
                android:layout_weight="1"
                android:background="@drawable/cell_shape"
                android:gravity="center"
                android:text="@string/TP_16_Range"
                android:textAppearance="?android:attr/textAppearanceMedium"
                android:textSize="20dp" />

            <CheckBox
                android:id="@+id/cb_2"
                android:layout_width="0dp"
                android:layout_height="65dp"
                android:layout_weight="1"
                android:background="@drawable/cell_shape"
                android:gravity="center" />
        </TableRow>

        <TableRow
            android:id="@+id/tableRow3_manual"
            android:layout_width="wrap_content"
            android:layout_height="0dp"
            android:layout_weight="1"
            android:gravity="center" >

            <TextView
                android:layout_width="0dp"
                android:layout_height="65dp"
                android:layout_weight="0.35"
                android:background="@drawable/cell_shape"
                android:gravity="center"
                android:text="@string/TP_17_Sno"
                android:textAppearance="?android:attr/textAppearanceMedium"
                android:textSize="20dp" />

            <TextView
                android:layout_width="0dp"
                android:layout_height="65dp"
                android:layout_weight="1.5"
                android:background="@drawable/cell_shape"
                android:gravity="center"
                android:text="@string/TP_17_Description"
                android:textAppearance="?android:attr/textAppearanceMedium"
                android:textSize="20dp" />

            <TextView
                android:layout_width="0dp"
                android:layout_height="65dp"
                android:layout_weight="1"
                android:background="@drawable/cell_shape"
                android:gravity="center"
                android:text="@string/Test_Point_17"
                android:textAppearance="?android:attr/textAppearanceMedium"
                android:textSize="20dp" />

            <TextView
                android:layout_width="0dp"
                android:layout_height="65dp"
                android:layout_weight="1"
                android:background="@drawable/cell_shape"
                android:gravity="center"
                android:text="@string/TP_17_Range"
                android:textAppearance="?android:attr/textAppearanceMedium"
                android:textSize="20dp" />

            <CheckBox
                android:id="@+id/cb_3"
                android:layout_width="0dp"
                android:layout_height="65dp"
                android:layout_weight="1"
                android:background="@drawable/cell_shape"
                android:gravity="center" />
        </TableRow>
</TableLayout>

This is what i had been facing but i need them in center




How to place check boxes in center in table layout

I am having a table layout having 12 rows and 5 columns for each row at the last column check box was there now I want to place my check box at the center of the check-box column can any one tell me how to place check box in center of table row in android

This is my drawable:

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://ift.tt/nIICcg" 
    android:shape="rectangle"
    >
    <solid android:color="#FFFFFF"/>
    <stroke android:width="1dp" android:color="#9e9e9e"/>


</shape>

This is my table layout

<RelativeLayout xmlns:android="http://ift.tt/nIICcg"
    xmlns:tools="http://ift.tt/LrGmb4"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="com.developer.milanandroid.Manual_AC_Fuse_ckt" >




    <TableLayout
        android:id="@+id/table_layout_manual_mode"
        android:layout_width="match_parent"

        android:shrinkColumns="3"
        android:stretchColumns="4" >

        <TableRow
            android:id="@+id/After_connection_heading_one"
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_weight="1"
            android:background="#673AB7" >

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginLeft="10dp"
                android:text="CHECK ON J14"
                android:textColor="#FFFFFF"
                android:textSize="20dp" />
        </TableRow>

        <TableRow
            android:id="@+id/tableRow1_manual"
            android:layout_width="wrap_content"
            android:layout_height="0dp"
            android:layout_weight="1"
            android:gravity="center" >

            <TextView
                android:id="@+id/textView1"
                android:layout_width="0dp"
                android:layout_height="65dp"
                android:layout_weight="0.35"
                android:background="@drawable/cell_shape"
                android:gravity="center"
                android:text="@string/TP_15_Sno"
                android:textAppearance="?android:attr/textAppearanceMedium"
                android:textSize="20dp" />

            <TextView
                android:id="@+id/textView2"
                android:layout_width="0dp"
                android:layout_height="65dp"
                android:layout_weight="1.5"
                android:background="@drawable/cell_shape"
                android:gravity="center"
                android:text="@string/TP_15_Description"
                android:textAppearance="?android:attr/textAppearanceMedium"
                android:textSize="20dp" />

            <TextView
                android:id="@+id/textView3"
                android:layout_width="0dp"
                android:layout_height="65dp"
                android:layout_weight="1"
                android:background="@drawable/cell_shape"
                android:gravity="center"
                android:text="@string/Test_Point_15"
                android:textAppearance="?android:attr/textAppearanceMedium"
                android:textSize="20dp" />

            <TextView
                android:id="@+id/textView4"
                android:layout_width="0dp"
                android:layout_height="65dp"
                android:layout_weight="1"
                android:background="@drawable/cell_shape"
                android:gravity="center"
                android:text="@string/TP_15_Range"
                android:textAppearance="?android:attr/textAppearanceMedium"
                android:textSize="20dp" />

            <CheckBox
                android:id="@+id/cb_1"
                android:layout_width="0dp"
                android:layout_height="65dp"
                android:layout_weight="1"
                android:background="@drawable/cell_shape"
                android:gravity="center"

                />
        </TableRow>

        <TableRow
            android:id="@+id/tableRow2_manual"
            android:layout_width="wrap_content"
            android:layout_height="0dp"
            android:layout_weight="1"
            android:gravity="center" >

            <TextView
                android:layout_width="0dp"
                android:layout_height="65dp"
                android:layout_weight="0.35"
                android:background="@drawable/cell_shape"
                android:gravity="center"
                android:text="@string/TP_16_Sno"
                android:textAppearance="?android:attr/textAppearanceMedium"
                android:textSize="20dp" />

            <TextView
                android:layout_width="0dp"
                android:layout_height="65dp"
                android:layout_weight="1.5"
                android:background="@drawable/cell_shape"
                android:gravity="center"
                android:text="@string/TP_16_Description"
                android:textAppearance="?android:attr/textAppearanceMedium"
                android:textSize="20dp" />

            <TextView
                android:layout_width="0dp"
                android:layout_height="65dp"
                android:layout_weight="1"
                android:background="@drawable/cell_shape"
                android:gravity="center"
                android:text="@string/Test_Point_16"
                android:textAppearance="?android:attr/textAppearanceMedium"
                android:textSize="20dp" />

            <TextView
                android:layout_width="0dp"
                android:layout_height="65dp"
                android:layout_weight="1"
                android:background="@drawable/cell_shape"
                android:gravity="center"
                android:text="@string/TP_16_Range"
                android:textAppearance="?android:attr/textAppearanceMedium"
                android:textSize="20dp" />

            <CheckBox
                android:id="@+id/cb_2"
                android:layout_width="0dp"
                android:layout_height="65dp"
                android:layout_weight="1"
                android:background="@drawable/cell_shape"
                android:gravity="center" />
        </TableRow>

        <TableRow
            android:id="@+id/tableRow3_manual"
            android:layout_width="wrap_content"
            android:layout_height="0dp"
            android:layout_weight="1"
            android:gravity="center" >

            <TextView
                android:layout_width="0dp"
                android:layout_height="65dp"
                android:layout_weight="0.35"
                android:background="@drawable/cell_shape"
                android:gravity="center"
                android:text="@string/TP_17_Sno"
                android:textAppearance="?android:attr/textAppearanceMedium"
                android:textSize="20dp" />

            <TextView
                android:layout_width="0dp"
                android:layout_height="65dp"
                android:layout_weight="1.5"
                android:background="@drawable/cell_shape"
                android:gravity="center"
                android:text="@string/TP_17_Description"
                android:textAppearance="?android:attr/textAppearanceMedium"
                android:textSize="20dp" />

            <TextView
                android:layout_width="0dp"
                android:layout_height="65dp"
                android:layout_weight="1"
                android:background="@drawable/cell_shape"
                android:gravity="center"
                android:text="@string/Test_Point_17"
                android:textAppearance="?android:attr/textAppearanceMedium"
                android:textSize="20dp" />

            <TextView
                android:layout_width="0dp"
                android:layout_height="65dp"
                android:layout_weight="1"
                android:background="@drawable/cell_shape"
                android:gravity="center"
                android:text="@string/TP_17_Range"
                android:textAppearance="?android:attr/textAppearanceMedium"
                android:textSize="20dp" />

            <CheckBox
                android:id="@+id/cb_3"
                android:layout_width="0dp"
                android:layout_height="65dp"
                android:layout_weight="1"
                android:background="@drawable/cell_shape"
                android:gravity="center" />
        </TableRow>

        <TableRow
            android:id="@+id/tableRow4_manual"
            android:layout_width="wrap_content"
            android:layout_height="0dp"
            android:layout_weight="1"
            android:gravity="center" >

            <TextView
                android:layout_width="0dp"
                android:layout_height="65dp"
                android:layout_weight="0.35"
                android:background="@drawable/cell_shape"
                android:gravity="center"
                android:text="@string/TP_18_Sno"
                android:textAppearance="?android:attr/textAppearanceMedium"
                android:textSize="20dp" />

            <TextView
                android:layout_width="0dp"
                android:layout_height="65dp"
                android:layout_weight="1.5"
                android:background="@drawable/cell_shape"
                android:gravity="center"
                android:text="@string/TP_18_Description"
                android:textAppearance="?android:attr/textAppearanceMedium"
                android:textSize="20dp" />

            <TextView
                android:layout_width="0dp"
                android:layout_height="65dp"
                android:layout_weight="1"
                android:background="@drawable/cell_shape"
                android:gravity="center"
                android:text="@string/Test_Point_18"
                android:textAppearance="?android:attr/textAppearanceMedium"
                android:textSize="20dp" />

            <TextView
                android:layout_width="0dp"
                android:layout_height="65dp"
                android:layout_weight="1"
                android:background="@drawable/cell_shape"
                android:gravity="center"
                android:text="@string/TP_18_Range"
                android:textAppearance="?android:attr/textAppearanceMedium"
                android:textSize="20dp" />

            <CheckBox
                android:id="@+id/cb_4"
                android:layout_width="0dp"
                android:layout_height="65dp"
                android:layout_weight="1"
                android:background="@drawable/cell_shape"
                android:gravity="center" />
        </TableRow>

        <TableRow
            android:id="@+id/tableRow5_manual"
            android:layout_width="wrap_content"
            android:layout_height="0dp"
            android:layout_weight="1"
            android:gravity="center" >

            <TextView
                android:layout_width="0dp"
                android:layout_height="65dp"
                android:layout_weight="0.35"
                android:background="@drawable/cell_shape"
                android:gravity="center"
                android:text="@string/TP_19_Sno"
                android:textAppearance="?android:attr/textAppearanceMedium"
                android:textSize="20dp" />

            <TextView
                android:layout_width="0dp"
                android:layout_height="65dp"
                android:layout_weight="1.5"
                android:background="@drawable/cell_shape"
                android:gravity="center"
                android:text="@string/TP_19_Description"
                android:textAppearance="?android:attr/textAppearanceMedium"
                android:textSize="20dp" />

            <TextView
                android:layout_width="0dp"
                android:layout_height="65dp"
                android:layout_weight="1"
                android:background="@drawable/cell_shape"
                android:gravity="center"
                android:text="@string/Test_Point_19"
                android:textAppearance="?android:attr/textAppearanceMedium"
                android:textSize="20dp" />

            <TextView
                android:layout_width="0dp"
                android:layout_height="65dp"
                android:layout_weight="1"
                android:background="@drawable/cell_shape"
                android:gravity="center"
                android:text="@string/TP_19_Range"
                android:textAppearance="?android:attr/textAppearanceMedium"
                android:textSize="20dp" />

            <CheckBox
                android:id="@+id/cb_5"
                android:layout_width="0dp"
                android:layout_height="65dp"
                android:layout_weight="1"
                android:background="@drawable/cell_shape"
                android:gravity="center" />
        </TableRow>

        <TableRow
            android:id="@+id/after_fuse_second_heading"
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_weight="1"
            android:background="#673AB7" >

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginLeft="10dp"
                android:text="CHECK ON P11"
                android:textColor="#FFFFFF"
                android:textSize="20dp" />
        </TableRow>

        <TableRow
            android:id="@+id/tableRow6_manual"
            android:layout_width="wrap_content"
            android:layout_height="0dp"
            android:layout_weight="1"
            android:gravity="center" >

            <TextView
                android:layout_width="0dp"
                android:layout_height="65dp"
                android:layout_weight="0.35"
                android:background="@drawable/cell_shape"
                android:gravity="center"
                android:text="@string/TP_20_Sno"
                android:textAppearance="?android:attr/textAppearanceMedium"
                android:textSize="20dp" />

            <TextView
                android:layout_width="0dp"
                android:layout_height="65dp"
                android:layout_weight="1.5"
                android:background="@drawable/cell_shape"
                android:gravity="center"
                android:text="@string/TP_20_Description"
                android:textAppearance="?android:attr/textAppearanceMedium"
                android:textSize="20dp" />

            <TextView
                android:layout_width="0dp"
                android:layout_height="65dp"
                android:layout_weight="1"
                android:background="@drawable/cell_shape"
                android:gravity="center"
                android:text="@string/Test_Point_20"
                android:textAppearance="?android:attr/textAppearanceMedium"
                android:textSize="20dp" />

            <TextView
                android:layout_width="0dp"
                android:layout_height="65dp"
                android:layout_weight="1"
                android:background="@drawable/cell_shape"
                android:gravity="center"
                android:text="@string/TP_20_Range"
                android:textAppearance="?android:attr/textAppearanceMedium"
                android:textSize="20dp" />

            <CheckBox
                android:id="@+id/cb_6"
                android:layout_width="0dp"
                android:layout_height="65dp"
                android:layout_weight="1"
                android:background="@drawable/cell_shape"
                android:gravity="center" />
        </TableRow>

        <TableRow
            android:id="@+id/tableRow7_manual"
            android:layout_width="wrap_content"
            android:layout_height="0dp"
            android:layout_weight="1"
            android:gravity="center" >

            <TextView
                android:layout_width="0dp"
                android:layout_height="65dp"
                android:layout_weight="0.35"
                android:background="@drawable/cell_shape"
                android:gravity="center"
                android:text="@string/TP_21_Sno"
                android:textAppearance="?android:attr/textAppearanceMedium"
                android:textSize="20dp" />

            <TextView
                android:layout_width="0dp"
                android:layout_height="65dp"
                android:layout_weight="1.5"
                android:background="@drawable/cell_shape"
                android:gravity="center"
                android:text="@string/TP_21_Description"
                android:textAppearance="?android:attr/textAppearanceMedium"
                android:textSize="20dp" />

            <TextView
                android:layout_width="0dp"
                android:layout_height="65dp"
                android:layout_weight="1"
                android:background="@drawable/cell_shape"
                android:gravity="center"
                android:text="@string/Test_Point_21"
                android:textAppearance="?android:attr/textAppearanceMedium"
                android:textSize="20dp" />

            <TextView
                android:layout_width="0dp"
                android:layout_height="65dp"
                android:layout_weight="1"
                android:background="@drawable/cell_shape"
                android:gravity="center"
                android:text="@string/TP_21_Range"
                android:textAppearance="?android:attr/textAppearanceMedium"
                android:textSize="20dp" />

            <CheckBox
                android:id="@+id/cb_7"
                android:layout_width="0dp"
                android:layout_height="65dp"
                android:layout_weight="1"
                android:background="@drawable/cell_shape"
                android:gravity="center" />
        </TableRow>



    </TableLayout>

         </ScrollView>


</RelativeLayout>




Listview setting check of checkboxess in listview

I have populated a simple listview with 4 rows. Each row has only one checkbox. Let us name them c0,c1,c2,c3 for convenience. I click, say c4 then c0 should also be checked as true if it is false. As soon as c4 is checked to false then c0 should also be checked as false.

Similarly, when c0 is clicked and found true then c1,c2,c3 should be set true. Similarly for the false case.

How do I get the position of c0 when c4 is clicked and vice-versa. Thanks anybody for you help!




dimanche 28 juin 2015

Checkboxes in listview are reset onPause of android

What i have: Listview with checkboxes hosted in activity

What is happening:

  1. onPause happens and the screen restores the checkboxes are re-setted to their original state

  2. How to resolve this


In activity

AdptHomeDetail serialNumbers = new AdptHomeDetail(ActMyOrderDetail.this, result.getMyOrderDetails().getSerialNumbers());
lstVwId.setAdapter(serialNumbers);

In Adapter

AdptHomeDetail.java

public class AdptHomeDetail extends BaseAdapter {

    ArrayList<SerialNumbers> mSerialNumbers;

    private Context mContext = null;

    public AdptHomeDetail(Context context, ArrayList<SerialNumbers> serialNo) {
        super();
        mContext = context;
        mSerialNumbers = serialNo;

    }

    public int getCount() {
        return mSerialNumbers.size();
    }

    public SerialNumbers getItem(int position) {
        return mSerialNumbers.get(position);
    }

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

    public View getView(final int position, View convertView, ViewGroup parent) {

        View view = convertView;

        final ViewHolder vHolder;
        if (convertView == null) {
            LayoutInflater layout = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            view = layout.inflate(R.layout.adp_act_myorder_detail, null);
            vHolder = new ViewHolder(view);
            view.setTag(vHolder);

            vHolder.checkBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

                @Override
                public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                    int getPosition = (Integer) buttonView.getTag();  // Here we get the position that we have set for the checkbox using setTag.
                    mSerialNumbers.get(getPosition).setIsChecked(buttonView.isChecked()); // Set the value of checkbox to maintain its state.
                }
            });

            view.setTag(R.id.checkBox, vHolder.checkBox);

        } else {
            vHolder = (ViewHolder) view.getTag();
        }

        vHolder.checkBox.setTag(position); // This line is important.
        vHolder.checkBox.setChecked(mSerialNumbers.get(position).isChecked()); // Restore the maintained checkbox state

        vHolder.txtNameId.setText(mSerialNumbers.get(position).getProduct().getName()) ;
        vHolder.txtSlnoId.setText(mContext.getResources().getString(R.string.myOrderDetailSlnoTag) + " " + mSerialNumbers.get(position).getSerial_num() + "") ;

        return view;
    }

    class ViewHolder {

        private TextView txtNameId,txtSlnoId;
        CheckBox checkBox;

        public ViewHolder(View base) {


     txtNameId = (TextView) base.findViewById(R.id.txtNameId);
        txtSlnoId = (TextView) base.findViewById(R.id.txtSlnoId);
        checkBox = (CheckBox) base.findViewById(R.id.checkBox);
    }
}

}




VB.net - Define what set to trigger based on the last textchanged event

In php and javascript I can do something like this

If ($a == 1){
  $set_num = 1
} Else {
  $set_num = 2
}

textbox_ . $set_num = "Some text here"
checkbox_ . $set_num = "Some text here"
radio_ . $set_num = "Some text here"

How can I do this in vb.net?

enter image description here

In my design page I have many textbox, checkbox and other things. What I want is to create a short code (Short as possible) so when the user types in a certain textbox I will know what schedule to activate so every time the user clicks the send button the system will just send the set that has a last text_change.

This is my code in vb.net, but it's not working

    Dim Set_Num As String

    If Cb_Set_1.Checked = True Then
        Set_Num = 1
    End If


    If "Cb_Sat_" & "Set_Num.Checked" = True Then
        b = 4
    Else
        b = 0
    End If




Why doesn't checkbox validation work in Parsley.js?

I can't for the life of me get Parsley.js to validate my checkboxes, even though my code looks just like their example. My HTML looks like this:

<div class='button-row'>
  <input data-parsley-mincheck='1' id='add-package-a-pre' name='add-package-alerts' type='checkbox' value='pre'>
  <label for='add-package-a-pre'>
    Pakke registrert
  </label>
  <input id='add-package-a-sent' name='add-package-alerts' type='checkbox' value='sent'>
  <label for='add-package-a-sent'>
    Pakke sendt
  </label>
  <input id='add-package-a-ready' name='add-package-alerts' type='checkbox' value='ready'>
  <label for='add-package-a-ready'>
    Pakke klar for henting
  </label>
  <input id='add-package-a-loaded' name='add-package-alerts' type='checkbox' value='loaded'>
  <label for='add-package-a-loaded'>
    Pakke lastet opp for utkjøring
  </label>
  <input id='add-package-a-delivered' name='add-package-alerts' type='checkbox' value='delivered'>
  <label for='add-package-a-delivered'>
    Pakke leveret
  </label>
</div>

Parsley works out of the box and prevents my form from submitting when I have an error in one of my text inputs, but it completely ignores the fact that none of my checkboxes are checked. As far as I can see, my code looks just like the example they provide: http://ift.tt/1jVPNN5

I have also made a JSFiddle that demonstrates the problem.

Can anybody see why it's not working? I've been stuck on this for hours now, and I can't find anybody else who's experiencing the same problem.




Javascript loop get name of checked checkbox

I have HTML to display checkbox those checked via a loop:

<!DOCTYPE html>

<html>
    <head>
        <title></title>
        <script src="http://ift.tt/1Gufy1b"></script>
    </head>

    <body>
        <form>
            <input type="checkbox" name="bla_bla1" id="checkbox_1" onchange="getName();"/>
            <input type="checkbox" name="bla_bla2" id="checkbox_2" onchange="getName();"/>
            <input type="checkbox" name="bla_bla3" id="checkbox_3" onchange="getName();"/>
        </form>     
        <span id="checkboxConfirm_1"></span>
        <span id="checkboxConfirm_2"></span>
        <span id="checkboxConfirm_3"></span>

        <script>            
            function getName(){
                for(i = 1; i<4; i++){
                var a = "#checkbox_".concat(i.toString()) ;
                var b = "#checkboxConfirm_".concat(i.toString());               

                if ((a).is(":checked")) {
                    $(b).text($(a).attr("name"));
                } else {
                    $(b).text('');
                }
            }
            }
        </script>   
    </body>
</html>

But Javascript not work. Please help me resolve the problem.




Get name checkbox those checked

I have HTML code:

<!-- Bid estate type. - -->
<table style="display: table;" id="bid">

        <tbody><tr>
            <td>
                <input name="Văn bản chấp thuận cho thuê đất của Cơ quan chức năng nhà nước" value="13" id="checkox_13" type="checkbox">


            </td>
            <td>
                <label for="doc-bid">
                    Văn bản chấp thuận cho thuê đất của Cơ quan chức năng nhà nước

                </label>
            </td>
            <td>
                <a class="button inline-button file-doc-link">Tải</a>
                <input name="file-doc-bid" type="file">
                <input name="id" value="13" type="hidden">
            </td>
        </tr>

        <tr>
            <td>
                <input name="Văn bản thông tin về kế hoạch cho thuê Lô đất của cơ quan chức năng nhà nước" value="14" id="checkox_14" type="checkbox">


            </td>
            <td>
                <label for="doc-bid">
                    Văn bản thông tin về kế hoạch cho thuê Lô đất của cơ quan chức năng nhà nước

                </label>
            </td>
            <td>
                <a class="button inline-button file-doc-link">Tải</a>
                <input name="file-doc-bid" type="file">
                <input name="id" value="14" type="hidden">
            </td>
        </tr>

        <tr>
            <td>
                <input name="Văn bản thông tin quy hoạch của Lô đất" value="15" id="checkox_15" type="checkbox">


            </td>
            <td>
                <label for="doc-bid">
                    Văn bản thông tin quy hoạch của Lô đất

                </label>
            </td>
            <td>
                <a class="button inline-button file-doc-link">Tải</a>
                <input name="file-doc-bid" type="file">
                <input name="id" value="15" type="hidden">
            </td>
        </tr>

        <tr>
            <td>
                <input name="Hồ sơ mốc giới Lô đất" value="16" id="checkox_16" type="checkbox">


            </td>
            <td>
                <label for="doc-bid">
                    Hồ sơ mốc giới Lô đất

                </label>
            </td>
            <td>
                <a class="button inline-button file-doc-link">Tải</a>
                <input name="file-doc-bid" type="file">
                <input name="id" value="16" type="hidden">
            </td>
        </tr>

        <tr>
            <td>
                <input name="Trích đo địa chính Lô đất" value="17" id="checkox_17" type="checkbox">


            </td>
            <td>
                <label for="doc-bid">
                    Trích đo địa chính Lô đất

                </label>
            </td>
            <td>
                <a class="button inline-button file-doc-link">Tải</a>
                <input name="file-doc-bid" type="file">
                <input name="id" value="17" type="hidden">
            </td>
        </tr>

        <tr>
            <td>
                <input name="Chưa có thông tin pháp lý" value="18" id="checkox_18" type="checkbox">


            </td>
            <td>
                <label for="doc-bid">
                    Chưa có thông tin pháp lý

                </label>
            </td>
            <td>
                <a class="button inline-button file-doc-link">Tải</a>
                <input name="file-doc-bid" type="file">
                <input name="id" value="18" type="hidden">
            </td>
        </tr>

</tbody></table>
<!-- Lease estate -->
<table style="display: none;" id="lease">

        <tbody><tr>
            <td>
                <input name="Giấy chứng nhận quyền sử dụng đất, sở hữu công trình gắn liền với đất" value="19" id="checkox_19" type="checkbox">
            </td>
            <td>
                <label for="doc-lease">
                    Giấy chứng nhận quyền sử dụng đất, sở hữu công trình gắn liền với đất
                </label>
            </td>
            <td>
                <a class="button inline-button file-doc-link">Tải</a>
                <input name="file-doc-lease" type="file">
                <input name="id" value="19" type="hidden">
            </td>
        </tr>

        <tr>
            <td>
                <input name="Giấy phép xây dựng" value="20" id="checkox_20" type="checkbox">
            </td>
            <td>
                <label for="doc-lease">
                    Giấy phép xây dựng
                </label>
            </td>
            <td>
                <a class="button inline-button file-doc-link">Tải</a>
                <input name="file-doc-lease" type="file">
                <input name="id" value="20" type="hidden">
            </td>
        </tr>

        <tr>
            <td>
                <input name="Bản vẽ thiết kế công trình trên đất" value="21" id="checkox_21" type="checkbox">
            </td>
            <td>
                <label for="doc-lease">
                    Bản vẽ thiết kế công trình trên đất
                </label>
            </td>
            <td>
                <a class="button inline-button file-doc-link">Tải</a>
                <input name="file-doc-lease" type="file">
                <input name="id" value="21" type="hidden">
            </td>
        </tr>

        <tr>
            <td>
                <input name="Bản vẽ hoàn công Công trình" value="22" id="checkox_22" type="checkbox">
            </td>
            <td>
                <label for="doc-lease">
                    Bản vẽ hoàn công Công trình
                </label>
            </td>
            <td>
                <a class="button inline-button file-doc-link">Tải</a>
                <input name="file-doc-lease" type="file">
                <input name="id" value="22" type="hidden">
            </td>
        </tr>

        <tr>
            <td>
                <input name="Giấy phép PCCC" value="23" id="checkox_23" type="checkbox">
            </td>
            <td>
                <label for="doc-lease">
                    Giấy phép PCCC
                </label>
            </td>
            <td>
                <a class="button inline-button file-doc-link">Tải</a>
                <input name="file-doc-lease" type="file">
                <input name="id" value="23" type="hidden">
            </td>
        </tr>

        <tr>
            <td>
                <input name="Quyết định cho thuê đất" value="24" id="checkox_24" type="checkbox">
            </td>
            <td>
                <label for="doc-lease">
                    Quyết định cho thuê đất
                </label>
            </td>
            <td>
                <a class="button inline-button file-doc-link">Tải</a>
                <input name="file-doc-lease" type="file">
                <input name="id" value="24" type="hidden">
            </td>
        </tr>

        <tr>
            <td>
                <input name="Hợp đồng thuê đất" value="25" id="checkox_25" type="checkbox">
            </td>
            <td>
                <label for="doc-lease">
                    Hợp đồng thuê đất
                </label>
            </td>
            <td>
                <a class="button inline-button file-doc-link">Tải</a>
                <input name="file-doc-lease" type="file">
                <input name="id" value="25" type="hidden">
            </td>
        </tr>

        <tr>
            <td>
                <input name="Quyết định phê duyệt đơn giá cho thuê đất đang áp dụng cho Lô đất" value="26" id="checkox_26" type="checkbox">
            </td>
            <td>
                <label for="doc-lease">
                    Quyết định phê duyệt đơn giá cho thuê đất đang áp dụng cho Lô đất
                </label>
            </td>
            <td>
                <a class="button inline-button file-doc-link">Tải</a>
                <input name="file-doc-lease" type="file">
                <input name="id" value="26" type="hidden">
            </td>
        </tr>

        <tr>
            <td>
                <input name="Hồ sơ mốc giới Lô đất" value="27" id="checkox_27" type="checkbox">
            </td>
            <td>
                <label for="doc-lease">
                    Hồ sơ mốc giới Lô đất
                </label>
            </td>
            <td>
                <a class="button inline-button file-doc-link">Tải</a>
                <input name="file-doc-lease" type="file">
                <input name="id" value="27" type="hidden">
            </td>
        </tr>

        <tr>
            <td>
                <input name="Trích đo địa chính Lô đất" value="28" id="checkox_28" type="checkbox">
            </td>
            <td>
                <label for="doc-lease">
                    Trích đo địa chính Lô đất
                </label>
            </td>
            <td>
                <a class="button inline-button file-doc-link">Tải</a>
                <input name="file-doc-lease" type="file">
                <input name="id" value="28" type="hidden">
            </td>
        </tr>

        <tr>
            <td>
                <input name="Chưa có thông tin pháp lý" value="29" id="checkox_29" type="checkbox">
            </td>
            <td>
                <label for="doc-lease">
                    Chưa có thông tin pháp lý
                </label>
            </td>
            <td>
                <a class="button inline-button file-doc-link">Tải</a>
                <input name="file-doc-lease" type="file">
                <input name="id" value="29" type="hidden">
            </td>
        </tr>

</tbody></table>
<!-- Transfer estate. -->
<table style="display: none;" id="transfer">

        <tbody><tr>
            <td>
                <input name="Thông báo đấu giá" value="1" id="checkox_1" type="checkbox">
            </td>
            <td>
                <label for="doc-transfer">
                    Thông báo đấu giá
                </label>
            </td>
            <td>
                <a class="button inline-button file-doc-link">Tải</a>
                <input name="file-doc-transfer" type="file">
                <input name="id" value="1" type="hidden">
            </td>
        </tr>

        <tr>
            <td>
                <input name="Quy chế đấu giá" value="2" id="checkox_2" type="checkbox">
            </td>
            <td>
                <label for="doc-transfer">
                    Quy chế đấu giá
                </label>
            </td>
            <td>
                <a class="button inline-button file-doc-link">Tải</a>
                <input name="file-doc-transfer" type="file">
                <input name="id" value="2" type="hidden">
            </td>
        </tr>

        <tr>
            <td>
                <input name="Giấy CNQSD đất, quyền sở hữu Công trình gắn liền với đất" value="3" id="checkox_3" type="checkbox">
            </td>
            <td>
                <label for="doc-transfer">
                    Giấy CNQSD đất, quyền sở hữu Công trình gắn liền với đất
                </label>
            </td>
            <td>
                <a class="button inline-button file-doc-link">Tải</a>
                <input name="file-doc-transfer" type="file">
                <input name="id" value="3" type="hidden">
            </td>
        </tr>

        <tr>
            <td>
                <input name="Giấy phép xây dựng" value="4" id="checkox_4" type="checkbox">
            </td>
            <td>
                <label for="doc-transfer">
                    Giấy phép xây dựng
                </label>
            </td>
            <td>
                <a class="button inline-button file-doc-link">Tải</a>
                <input name="file-doc-transfer" type="file">
                <input name="id" value="4" type="hidden">
            </td>
        </tr>

        <tr>
            <td>
                <input name="Bản vẽ thiết kế công trình trên đất" value="5" id="checkox_5" type="checkbox">
            </td>
            <td>
                <label for="doc-transfer">
                    Bản vẽ thiết kế công trình trên đất
                </label>
            </td>
            <td>
                <a class="button inline-button file-doc-link">Tải</a>
                <input name="file-doc-transfer" type="file">
                <input name="id" value="5" type="hidden">
            </td>
        </tr>

        <tr>
            <td>
                <input name="Bản vẽ hoàn công Công trình" value="6" id="checkox_6" type="checkbox">
            </td>
            <td>
                <label for="doc-transfer">
                    Bản vẽ hoàn công Công trình
                </label>
            </td>
            <td>
                <a class="button inline-button file-doc-link">Tải</a>
                <input name="file-doc-transfer" type="file">
                <input name="id" value="6" type="hidden">
            </td>
        </tr>

        <tr>
            <td>
                <input name="Hợp đồng thuê đất (nếu là đất thuê)" value="7" id="checkox_7" type="checkbox">
            </td>
            <td>
                <label for="doc-transfer">
                    Hợp đồng thuê đất (nếu là đất thuê)
                </label>
            </td>
            <td>
                <a class="button inline-button file-doc-link">Tải</a>
                <input name="file-doc-transfer" type="file">
                <input name="id" value="7" type="hidden">
            </td>
        </tr>

        <tr>
            <td>
                <input name="Quyết định phê duyệt đơn giá cho thuê đất đang áp dụng cho Lô đất" value="8" id="checkox_8" type="checkbox">
            </td>
            <td>
                <label for="doc-transfer">
                    Quyết định phê duyệt đơn giá cho thuê đất đang áp dụng cho Lô đất
                </label>
            </td>
            <td>
                <a class="button inline-button file-doc-link">Tải</a>
                <input name="file-doc-transfer" type="file">
                <input name="id" value="8" type="hidden">
            </td>
        </tr>

        <tr>
            <td>
                <input name="Hồ sơ mốc giới lô đất" value="9" id="checkox_9" type="checkbox">
            </td>
            <td>
                <label for="doc-transfer">
                    Hồ sơ mốc giới lô đất
                </label>
            </td>
            <td>
                <a class="button inline-button file-doc-link">Tải</a>
                <input name="file-doc-transfer" type="file">
                <input name="id" value="9" type="hidden">
            </td>
        </tr>

        <tr>
            <td>
                <input name="Trích đo địa chính lô đất" value="10" id="checkox_10" type="checkbox">
            </td>
            <td>
                <label for="doc-transfer">
                    Trích đo địa chính lô đất
                </label>
            </td>
            <td>
                <a class="button inline-button file-doc-link">Tải</a>
                <input name="file-doc-transfer" type="file">
                <input name="id" value="10" type="hidden">
            </td>
        </tr>

        <tr>
            <td>
                <input name="Văn bản khác liên quan đến Lô đất và Công trình gắn liền với đất" value="11" id="checkox_11" type="checkbox">
            </td>
            <td>
                <label for="doc-transfer">
                    Văn bản khác liên quan đến Lô đất và Công trình gắn liền với đất
                </label>
            </td>
            <td>
                <a class="button inline-button file-doc-link">Tải</a>
                <input name="file-doc-transfer" type="file">
                <input name="id" value="11" type="hidden">
            </td>
        </tr>

        <tr>
            <td>
                <input name="Chưa có thông tin pháp lý" value="12" id="checkox_12" type="checkbox">
            </td>
            <td>
                <label for="doc-transfer">
                    Chưa có thông tin pháp lý
                </label>
            </td>
            <td>
                <a class="button inline-button file-doc-link">Tải</a>
                <input name="file-doc-transfer" type="file">
                <input name="id" value="12" type="hidden">
            </td>
        </tr>

</tbody></table>

I need display confirm screen before user press Submit button:

<span id="checkbox_1Confirm"></span>
<span id="checkbox_2Confirm"></span>
....
<span id="checkbox_nConfirm"></span>

I try something like this (use jQuery):

if($("#checkbox_1").checked) {
    $("#checkboxConfirm_1").text($("#checkbox_1").attr("name").val());
}

but It doesn't work. I also try a loop, and only display checkbox checked, but not successful.