jeudi 30 janvier 2020

How to display only the selected option for several chosen checkboxes of my displayed csv file column headers

  
  <table border="0" cellspacing="1" cellpadding="1" class="sortable" >

   

  <?php
      #read CSV file
      $uploadfile = $_SESSION['uploadCsv'];
      
      if (($handle = fopen($uploadfile, "r")) !== FALSE) {
        $mycsv = array();
        while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) 
        $mycsv[] = $data;
        fclose($handle);


      #Find the length of the transposed row

      $row_length = count($mycsv);
      
      echo "<form method='post' action=''><table><tr>";
      echo "<th><input type='checkbox' onClick='toggle(this)' /> Select/Deselect All<br/>
      </th>";
      echo "<th>Column</th>";
      echo "<th>Filter</th>";


      echo "</tr>";

      #Loop through each row (or each line in the csv) and output all the columns for that row
      foreach($mycsv[0] as $col_num => $col)
      {
          

        echo "<tr>";
          
    
    
          for($x=0; $x<1; $x++)
          {
              
          

          echo "<td><input type='checkbox' name='lang[]'  value='".$mycsv[$x][$col_num]."' ></td>";
          echo "<td align='center'>"  .$mycsv[$x][$col_num]."</td>";
          echo "<td>
            <select name='method[]' >
             <option value=''>Choose</option>
              <option  value='sum'>Sum</option>
              <option  value='mean'>Mean</option>
              <option  value='standard deviation'>Standard deviation</option>
              <option  value='mode'>Mode</option>
            </select>
              </td>";
          echo "</tr>";
          }
          
      }
          echo "<tr>";
          echo "<td><input type='checkbox' name='lang[]' ></td>";
          echo "<td align='center'><input type='text' name='own_column' placeholder='Type your new column here'><br></td>";
          echo "<td><input type='text' name='own_column' placeholder='Own formula'><br></td>";
          echo "</tr>";

          //echo "<tr>";
          //echo "<td colspan='3' align='center'><input type='submit' name='Order'/></td>";
          //echo "</tr>";
          echo "<tr>";
          echo "<td colspan='3'><div class='wrapper'><br/><br/><input type='button' class='button' value='Input Button'>
          </div></td>";
          echo "</tr>
          <input type='submit' value='submit' name='submit'<table></form>";
            }

  ?>
  </tbody>


 <div style="border:solid 2px red;width:50%;">
 <?php

$package = $_POST['method'];
if(isset($_POST['submit'])){

   if(!empty($_POST['lang'])) {

       foreach($_POST['lang'] as $value){
          echo "<tr><td>";
           echo " value : ".$value.'<br/>';
           echo "</td></tr>";

          if(!empty($_POST['method'])) 
           {

           foreach($_POST['method'] as $method){
            if($method == 'sum')
            {
              echo "<tr><td>";
              echo "Sum of ".$value."";
              echo "</td></tr>";
            } else if ($method == 'mean')
            {
              echo "<tr><td>";
              echo "mean of ".$value."";
              echo "</td></tr>";
            }else if ($method == 'mode')
            {
              echo "<tr><td>";
              echo "mode";
              echo "</td></tr>";
            }
            {
              echo"no links";
            }
  
                //echo "method : ".$method.'<br/>';
          }
        
           }

          

       }

   }

  

}
?>

enter image description here I am using a form which have check-boxes and select option. Upon import of my csv files using PHP, it displays the data correctly with the column headers. However having real trouble on how to display the CHECKED-boxes with its selected option only.

enter image description here how do I display on the selected option for the selected checkbox. Please help.




get the checked value in another activity.The checkboxes are in alert dialog box

I have buttons in an activity.On clicking any button an alert dialog opens up with the check boxes .The user clicks on any checkbox and the value is stored in array list.Now I want to receive the check boxes value in another activity and print the value of the checked values saying these are the checked values.How can you do the same?




Show that a checkbox is already selected, how to set an attribute "checked" in tag?

I want to show that a checkbox is already selected when I press update button to edit in the field, then I have set an attribute "checked" in tag, but it can't able work, my input checkbox coding like below:

Checkbox coding


    <div class="form-group col-lg-6">
                        <label class="control-label col-lg-4">Pricing<span style="color:red;">&nbsp;</span></label>
                        <div class="col-lg-8">
                        <input type="checkbox" name="rm_option" id="rm_option" value="1" <?= $_POST['rm_option'] == 1:'checked':''?>><strong> RM </strong></input>&nbsp;&nbsp;&nbsp;
                        <input type="checkbox" name="point_option" id="point_option" value="1" <?= $_POST['point_option'] == 1:'checked':''?>><strong> Full Point </strong></input>&nbsp;&nbsp;&nbsp;
                        <input type="checkbox" name="partial_option" id="partial_option" value="1" <?= $_POST['partial_option'] == 1:'checked':''?>><strong> Partial Point + RM  </strong></input>&nbsp;&nbsp;&nbsp;

                        </div>
                        </div>

update function coding:

if ($action == 'save') {
    //echo "test";
    $id_merchant_list=get_tbl_val('merchant_list','id','id_user',$user_id);

    $column_key_insert[] = 'active';
   $column_val_insert[] = convert_db_value(1);
    $key_relationship_1[] = 'created';
    $val_relationship_1[] = convert_db_value($cur_dt);
    $key_relationship_1[] = 'createdby';
    $val_relationship_1[] = convert_db_value($user_name);
    $key_relationship_1[] = 'modified';
    $val_relationship_1[] = convert_db_value($cur_dt);
    $key_relationship_1[] = 'modifiedby';
    $val_relationship_1[] = convert_db_value($user_name);
    $key_relationship_1[] = 'p_or_ld';
    $val_relationship_1[] = convert_db_value('1');
    $key_relationship_1[] = 'id_merchant_list';
    $val_relationship_1[] = convert_db_value($id_merchant_list);
    $key_relationship_1[] = 'id_promotion_categories';
    $val_relationship_1[] = convert_db_value($_POST['id_promotion_categories']);
    $key_relationship_1[] = 'promotion_title';
    $val_relationship_1[] = convert_db_value($_POST['promotion_title']);
    $key_relationship_1[] = 'rm_option';
    $val_relationship_1[] = convert_db_value($_POST['rm_option']);
    $key_relationship_1[] = 'point_option';
    $val_relationship_1[] = convert_db_value($_POST['point_option']);
    $key_relationship_1[] = 'partial_option';
    $val_relationship_1[] = convert_db_value($_POST['partial_option']);
    $key_relationship_1[] = 'point_rm_rm';
    $val_relationship_1[] = convert_db_value($_POST['point_rm_rm']);
    $key_relationship_1[] = 'rm';
    $val_relationship_1[] = convert_db_value($_POST['rm']);
    $key_relationship_1[] = 'point';
    $val_relationship_1[] = convert_db_value($_POST['point']);
    $key_relationship_1[] = 'point_rm_point';
    $val_relationship_1[] = convert_db_value($_POST['point_rm_point']);
    $key_relationship_1[] = 'quantity_limit_option';
    $val_relationship_1[] = convert_db_value($_POST['quantity_limit_option']);
    $key_relationship_1[] = 'quantity_limit';
    $val_relationship_1[] = convert_db_value($_POST['quantity_limit']);
    $key_relationship_1[] = 'promotion_price_before';
    $val_relationship_1[] = convert_db_value($_POST['promotion_price_before']);
    $key_relationship_1[] = 'promotion_price_after';
    $val_relationship_1[] = convert_db_value($_POST['promotion_price_after']);
    $key_relationship_1[] = 'promotion_description';
    $val_relationship_1[] = convert_db_value($_POST['promotion_description']);
    $key_relationship_1[] = 'reservation';
    $val_relationship_1[] = convert_db_value($_POST['reservation']);
    $key_relationship_1[] = 'feature';
    $val_relationship_1[] = convert_db_value($_POST['feature']);
    $key_relationship_1[] = 'redemption_from_date';
    $val_relationship_1[] = convert_db_value($_POST['redemption_from_date']);
    $key_relationship_1[] = 'redemption_to_date';
    $val_relationship_1[] = convert_db_value($_POST['redemption_to_date']);
    $key_relationship_1[] = 'promotion_content';
    $val_relationship_1[] = convert_db_value($_POST['promotion_content']);
    $key_relationship_1[] = 'promotion_terms';
    $val_relationship_1[] = convert_db_value($_POST['promotion_terms']);
    $key_relationship_1[] = 'promotion_instruction';
    $val_relationship_1[] = convert_db_value($_POST['promotion_instruction']);
    $key_relationship_1[] = 'promotion_policy';
    $val_relationship_1[] = convert_db_value($_POST['promotion_policy']);
    $key_relationship_1[] = 'discount_percentage';
    $val_relationship_1[] = convert_db_value($_POST['discount_percentage']);
    $key_relationship_1[] = 'merchant_option';
    $val_relationship_1[] = convert_db_value($_POST['merchant_option']);
    $key_relationship_1[] = 'merchant_price';
    $val_relationship_1[] = convert_db_value($_POST['merchant_price']);
    $row_insert = db_conn_insert('promotion_list', $key_relationship_1, $val_relationship_1);
    $sql_insert = $row_insert['sql'];
    $error_insert = $row_insert['error'];
    $record_id = $row_insert['record_id'];

    unset($key_relationship_1);
    unset($val_relationship_1);
    if ($row_insert) {
        echo 'Saved successfully';
        // echo $sql_insert; 
    }
} 
else if ($action == 'update') {
    $id = isset($_POST['filter_id']) ? $_POST['filter_id'] : "";
    $id_promotion_categories = isset($_POST['id_promotion_categories']) ? $_POST['id_promotion_categories'] : "";
    $promotion_title = isset($_POST['promotion_title']) ? $_POST['promotion_title'] : "";
    $promotion_description = isset($_POST['promotion_description']) ? $_POST['promotion_description'] : "";
    $reservation = isset($_POST['reservation']) ? $_POST['reservation'] : "";
    $feature = isset($_POST['feature']) ? $_POST['feature'] : "";
    $discount_percentage = isset($_POST['discount_percentage']) ? $_POST['discount_percentage'] : "";
    $promotion_price_before = isset($_POST['promotion_price_before']) ? $_POST['promotion_price_before'] : "";
    $promotion_price_before = isset($_POST['promotion_price_before']) ? $_POST['promotion_price_before'] : "";

    $rm = isset($_POST['rm']) ? $_POST['rm'] : "";
    $point = isset($_POST['point']) ? $_POST['point'] : "";
    $partial_point = isset($_POST['point_rm_point']) ? $_POST['point_rm_point'] : "";
    $partial_rm = isset($_POST['point_rm_rm']) ? $_POST['point_rm_rm'] : "";

    $rm_option = isset($_POST['rm_option ']) ? $_POST['rm_option '] : "";
    $point_option = isset($_POST['point_option ']) ? $_POST['point_option '] : "";
    $partial_option = isset($_POST['partial_option ']) ? $_POST['partial_option '] : "";

    $query = "UPDATE ".$table.
    " SET id_promotion_categories = '".$id_promotion_categories.
    "', promotion_title = '".$promotion_title.
    "', promotion_description = '".$promotion_description.
    "', reservation = '".$reservation.
    "',rm = '".$rm.
    "',point = '".$point.
    "',point_rm_point = '".$partial_point.
    "',point_rm_rm = '".$partial_rm.
    "',rm_option = '".$rm_option.
    "',point_option = '".$point_option.
    "',partial_option = '".$partial_option.
    "', feature = '".$feature.
    "' where id='".$id.
    "'";

    $arr_treatment = db_conn_update($query);

    if ($arr_treatment) {

        $result_arr['msg'] = 'Update Successful';
    } else {
        $result_arr['msg'] = 'Error in processing data. Please try again later.';
    }
    $result_arr = special_char_display_arr($result_arr);
    $json = json_encode($result_arr);
    print($json);

} else if ($action == 'edit') {
    $id = isset($_POST['id']) ? $_POST['id'] : "";
    $sql = 'SELECT *  FROM promotion_list WHERE id = '.$id;
    $result_arr['sql'] = $sql;
    $result_arr = get_tbl_row($sql);
    //$result_arr['treatment_category_name'] = get_tbl_val('treatment_category_list', 'id', 'name', $result_arr['category']);
    $result_arr = special_char_display_arr($result_arr);
    $json = json_encode($result_arr);
    print($json);

Below is my output, the red box and the arrow means it unable to show me the previous record to update when I press the update button, then how to remove >in the chekckbox(> RM) :

Output

Hope someone can guide me how to solve it. Thanks.




How to make select all checkbox and delete selected item in kotlin?

Outside the recycler view, there are Select All and Delete Select. I'm already working on creating a Select Delete button and a Select All button. However, if I click one checkbox before clicking Select All, and then click Select All, the selected checkbox is unchecked. My delete function also works strangely. I must delete the checked items, but other items are deleted. How can I solve this problem? How do I create a loop that checks a checkbox? Please look at my code and help me.

CartViewActivity

class CartViewActivity : AppCompatActivity(), SwipeRefreshLayout.OnRefreshListener {




    internal lateinit var mAdapter: CartItemRecyclerAdapter

    @RequiresApi(Build.VERSION_CODES.N)
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_cart_view)

        val page = 0
        val token = SharedPreference.getTokenInfo(this)
        SharedPreference.removeAll(this, "key")
        Client.retrofitService.getCart(token,page).enqueue(object :Callback<CartResponse> {
            override fun onResponse(call: Call<CartResponse>, response: Response<CartResponse>) {
                if (response?.isSuccessful == true) {
                    swipeRefreshLo.setOnRefreshListener(this@CartViewActivity)
                    showdata(response.body()?.docs!!)

                }else if(response?.isSuccessful==false) {
                    val er = Gson().fromJson(response.errorBody()?.charStream(), ErrorResponse::class.java)
                    if (er.code==60202) {

                    }
                }
            }
            override fun onFailure(call: Call<CartResponse>, t: Throwable) {

            }

        })

        selectAll.setOnClickListener{

            if (selectAll.isChecked) {
                selectAll.buttonDrawable = it.context.getDrawable(R.drawable.check_box_active_cs)
                mAdapter.toggleItems()
                val layout = findViewById(R.id.layoutOrder) as LinearLayout
                layout.visibility= View.VISIBLE
            }else {
                selectAll.buttonDrawable = it.context.getDrawable(R.drawable.check_box_no)
                mAdapter.toggleItems()
                val layout = findViewById(R.id.layoutOrder) as LinearLayout
                layout.visibility = View.GONE
            }

        }

        selectDelete.setOnClickListener {
               val items = SharedPreference.readSelect(this, "key")
                val param = select((items))
                Client.retrofitService.removeCart(token, param).enqueue(object : Callback<deleteResponse>{
                    override fun onResponse(call: Call<deleteResponse>, response: Response<deleteResponse>
                    ) {

                            SharedPreference.removeAll(applicationContext, "key")
mAdapter.removeItems()

                    }
                    override fun onFailure(call: Call<deleteResponse>, t: Throwable) {

                    }

                })
            }
        }

    private fun showdata(results: ArrayList<cartDocs>) {
        recycler_view.apply {
            mAdapter=CartItemRecyclerAdapter(context,context as Activity, results)
            recycler_view.adapter=mAdapter
            recycler_view.layoutManager=LinearLayoutManager(context)

        }
    }

    override fun onRefresh() {
        swipeRefreshLo.isRefreshing = false
    }
  }

CartItemRecyclerAdapter

class CartItemRecyclerAdapter(val context: Context, private var activity : Activity, private val dataList: ArrayList<cartDocs>) : RecyclerView.Adapter<CartItemRecyclerAdapter.Holder>() {


    companion object {
        var checkedItems = ArrayList<cartDocs>()
    }


    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): Holder {
        val view = LayoutInflater.from(context).inflate(R.layout.cart_item_list, parent, false)
        return Holder(view)
    }

    override fun onBindViewHolder(holder: Holder, position: Int) {
        holder.bind(dataList.get(position), context)
        Glide.with(context).load(dataList.get(position).mainImage).into(holder.imageView)

    }

    override fun getItemCount(): Int = dataList.size


    @RequiresApi(Build.VERSION_CODES.N)
    fun removeItems(                                                                                                                                                                                                                                                                                                                                                                                                                       ) {
        dataList.removeIf { it.isSelected }
        notifyDataSetChanged()
    }


    fun toggleItems() {
        for (item: cartDocs in dataList) {
            var state = item.isSelected
            item.isSelected = !state

        }
        notifyDataSetChanged()
    }


    inner class Holder(itemView: View?) : RecyclerView.ViewHolder(itemView!!) {


        var titleText = itemView?.findViewById(R.id.titleText) as TextView
        var temNumerTextt = itemView?.findViewById(R.id.textViewItemNumer) as TextView
        var priceText = itemView?.findViewById(R.id.priceText) as TextView
        var pointValueText = itemView?.findViewById(R.id.pointValueText) as TextView
        var imageView = itemView?.findViewById(R.id.imageView) as ImageView
        var checkBox = itemView?.findViewById(R.id.checkBox) as CheckBox
        var deleteBox = itemView?.findViewById(R.id.delete) as Button
        var order = itemView?.findViewById(R.id.btnOrder) as Button


        val token = SharedPreference.getTokenInfo(context)



        fun bind(data: cartDocs, context: Context) {
            val dec = DecimalFormat("##,000")
            priceText.text = dec.format(data.price).toString() 
            titleText.text = data.title
            temNumerTextt.text = data.amount.toString()
            pointValueText.text = dec.format(data.price).toString()


            val value3 = dataList.size.toString()
            if (value3 != null) {
                SharedPreference.setThirdText(context, value3)
            }
            if (data.isSelected) {
                checkBox.buttonDrawable =
                    checkBox.context.getDrawable(R.drawable.check_box_active_cs)
                val layout = activity.findViewById(R.id.layoutOrder) as LinearLayout
                layout.visibility = View.VISIBLE
            } else {
                checkBox.buttonDrawable = checkBox.context.getDrawable(R.drawable.check_box_no)
                val layout = activity.findViewById(R.id.layoutOrder) as LinearLayout
                layout.visibility = View.GONE
            }


            order.setOnClickListener {
                val i = Intent(it.context, PaymentActivity::class.java)
                i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
                it.context.startActivity(i)

            }


            deleteBox.setOnClickListener {
                val item = data.id
                Client.retrofitService.deleteCart(token, item)
                    .enqueue(object : retrofit2.Callback<deleteResponse> {
                        override fun onResponse(
                            call: Call<deleteResponse>, response: Response<deleteResponse>
                        ) {
                            dataList.removeAt(adapterPosition)
                            notifyItemRemoved(adapterPosition)
                            notifyItemRangeChanged(adapterPosition, dataList.size)
                            val layout = activity.findViewById(R.id.layoutOrder) as LinearLayout
                            layout.visibility = View.GONE

                        }

                        override fun onFailure(call: Call<deleteResponse>, t: Throwable) {

                        }
                    })
            }


            checkBox.setOnCheckedChangeListener { buttonView, isChecked ->
                data.isSelected = !data.isSelected
                if (isChecked) {
//                   
                    checkBox.buttonDrawable = context.getDrawable(R.drawable.check_box_active_cs)
                    val item = data.id
                    val listSelected: ArrayList<String> =
                        SharedPreference.readSelect(context, "key")
                    listSelected.add(item!!)
                    SharedPreference.saveSelect(context, listSelected, "key")
                    val layout = activity.findViewById(R.id.layoutOrder) as LinearLayout
                    layout.visibility = View.VISIBLE
                } else {
                    SharedPreference.cartRemove(context, "key")
                    checkBox.buttonDrawable = context.getDrawable(R.drawable.check_box_no)
                    val layout = activity.findViewById(R.id.layoutOrder) as LinearLayout
                    layout.visibility = View.GONE
                }

                checkedItems.clear()
                for (cartDocs in dataList) {
                    if (cartDocs.isSelected) {
                        checkedItems.add(cartDocs)
                    }
                }

                Log.d("cart", "checked items : " + checkedItems.count())
                if (checkedItems.count()!==0) {
                    val layout = activity.findViewById(R.id.layoutOrder) as LinearLayout
                    layout.visibility = View.VISIBLE
                }else if (checkedItems.count()==0) {
                    val layout = activity.findViewById(R.id.layoutOrder) as LinearLayout
                    layout.visibility = View.GONE
                }


            }
        }
    }
}




Android checkbox without check mark on smartphone (emulator is working)

I have some checkboxs that don't work correctly. Checkboxs result checked but there are no check marks. If click on checkbox twice, check mark appears. On the emulator there are no problem, but on my Galaxy S7 (Oreo) there is this bug. Is it possibile to fix? Thank you enter image description here




STRIKE_THRU_TEXT_FLAG not working as Expected

This is my RecyclerView Adaptor Class

public class TodoAdaptor extends RecyclerView.Adapter<TodoAdaptor.SingleTodoView> {

    private CheckBox checkbox;
    private TextView title, dueDate;
    private Context context;
    private ArrayList<SingleTodo> todoList;
    private onItemCLickListener itemCLickListener;

    public TodoAdaptor(Context context, ArrayList<SingleTodo> todoList, onItemCLickListener onItemClickListener) {
        this.context = context;
        this.todoList = todoList;
        this.itemCLickListener = onItemClickListener;
    }


    @NonNull
    @Override
    public SingleTodoView onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.single_todo, parent, false);
        return new SingleTodoView(v, itemCLickListener);
    }

    @Override
    public void onBindViewHolder(@NonNull SingleTodoView holder, int position) {
        SingleTodo singleTodo = todoList.get(position);
        checkbox.setChecked(singleTodo.isComplete());
        title.setText(singleTodo.getTitle());
         if (singleTodo.isComplete()) {
            title.setPaintFlags(title.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);
            Toast.makeText(context, "IsCompleted", Toast.LENGTH_SHORT).show();
        } else {
            title.setPaintFlags(title.getPaintFlags() & (~Paint.STRIKE_THRU_TEXT_FLAG));
            Toast.makeText(context, "Not IsCompleted", Toast.LENGTH_SHORT).show();
        }
        if (singleTodo.getDueDate().isEmpty()) {
            dueDate.setVisibility(View.GONE);
        } else {
            dueDate.setText(singleTodo.getDueDate());
        }
    }

    @Override
    public int getItemCount() {
        return todoList.size();
    }

    class SingleTodoView extends RecyclerView.ViewHolder {

        private SingleTodoView(@NonNull View itemView, final onItemCLickListener itemCLickListener) {
            super(itemView);
            checkbox = itemView.findViewById(R.id.todo_list_completed_checkbox);
            title = itemView.findViewById(R.id.todo_list_title);
            dueDate = itemView.findViewById(R.id.todo_list_due_date);
            title.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    itemCLickListener.onTextClickListener(getAdapterPosition());
                }
            });
            checkbox.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    itemCLickListener.onCheckboxClickListener(getAdapterPosition());
                }
            });
        }
    }

    public interface onItemCLickListener {
        void onTextClickListener(int position);
        void onCheckboxClickListener(int position);
    }
}

This is My Adaptor

 todoAdaptor = new TodoAdaptor(this, singleTodoArrayList, new TodoAdaptor.onItemCLickListener() {
            @Override
            public void onTextClickListener(int position) {
                singleTodo = singleTodoArrayList.get(position);
                singleTodo.setTitle("This is Test");
                singleTodoArrayList.set(position, singleTodo);
                todoAdaptor.notifyItemChanged(position);
            }

            @Override
            public void onCheckboxClickListener(int position) {
                singleTodo = singleTodoArrayList.get(position);
                singleTodo.setComplete(!singleTodo.isComplete());
                singleTodoArrayList.set(position, singleTodo);
                todoAdaptor.notifyItemChanged(position);
            }
        });

and This is my SingleTodo Class

package com.example.simpletodo.classes;

public class SingleTodo {
    private int id;
    private String title;
    private String dueDate;
    private boolean isComplete;

    public SingleTodo(int id, String title, String dueDate, boolean isComplete) {
        this.id = id;
        this.title = title;
        this.dueDate = dueDate;
        this.isComplete = isComplete;
    }

    public int getId() {
        return id;
    }

    public String getTitle() {
        return title;
    }

    public String getDueDate() {
        return dueDate;
    }

    public boolean isComplete() {
        return isComplete;
    }

    public void setId(int id) {
        this.id = id;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public void setDueDate(String dueDate) {
        this.dueDate = dueDate;
    }

    public void setComplete(boolean complete) {
        isComplete = complete;
    }
}

Whenever I check the checkbox, Text of that item should paint Strikethrough and Its not working as Expected

I have 3 Items in the list, when i click checkbox Item get Checked and Text Strikethrough works but when i again click checkbox checkbox stay checked (although Object is being Updated as it should be) and strikethrought text revert to normal, and i have to click checkbox twice again for check box to get unchecked

other issue is that when i checked on item and then i try to check other item, Current Item text get replaced by one of the other checked item Text. Images :
Default:
Default
When i click the Checkbox Once:
Clicked on Checkbox Once
When i Click the Checkbox Again:
Checkbox Checked Twice
When i Checked multiple Items one by one(I have not changed position of any item before checking they was in default order and after checking --in order-- this is what i get)
multiple Checkbox Issue
Any Help is Appreciated. I just want my code to work as Expected.




issue with standard checkbox and image

I'm really scratching my head on why I am not seeing the image appear when I click on the checkbox. I get no errors with Inspect Tools. Does anyone see something I am missing? Thank you.

<!DOCTYPE html>
<html lang="en" dir="ltr">
   <head>
    <meta charset="utf-8">
    <title></title>
    <style>
        #your_img {
       display: none;
        }

    </style>
    <script src="https://code.jquery.com/jquery-3.4.1.js" integrity="sha256-WpOohJOqMqqyKL9FccASB9O0KwACQJpFTUBLTYOVvVU=" crossorigin="anonymous"></script>

    <script type="text/javascript">
        $('#show_image').on("click", function() {
          if ($('#your_img').is(':hidden')) {
            $('#your_img').show();
          } else {
            $('#your_img').hide();
          }
        });
    </script>

    </head>
    <input type="checkbox" id="show_image">Show Image</input>
    <div id="your_img">
    <img src="https://saltwx.com/images/chloro/chloro_bar.png" alt="A image" style="height: 
    485px;width:71px">
    </div>
    <body>

</body>
</html>



Get selected nodes from treeview UWP

I am developing UWP app, and I am struggling with treeview checkboxes. I need to know which nodes have checkboxes checked.

I have tried using

mytreeview.SelectedNodes 

but it always returns null. This is my treeview I have also tried using

<TreeViewItem IsSelected="{x:Bind IsSelected ,Mode=TwoWay}" ...>

and in page.cs

public bool IsSelected { get; set; } = false;

but when I check the checkbox it is still false




textbox not hiding with checkbox click (javascript)

I have a textbox which I would like to appear on a checkbox click and disappear if the checkbox is unselected, however my code currently shows the textbox when the page loads, but once you select and then unselect the checkbox it disappears as its supposed to. Any ideas?

Javascript:

function TMDFunction() {
  // Get the checkbox
  var checkBox = document.getElementById("tmd_checkbox");
  // Get the output text
  var text = document.getElementById("test");

  // If the checkbox is checked, display the output text
  if (checkBox.checked == true) {
    text.style.display = 'block';
  } else {
    text.style.display = 'none';
  }
}
<input type="checkbox" class="product" name="targetedmobiledisplay" value="0.08" id="tmd_checkbox" onclick="TMDFunction()">
Targeted Mobile Display
<br> 
Test: <input id="test" type="text" value="0.00" data-total="0" />



What attributes make a checkbox uncheckable? (Bootstrap/AdminLTE)

I have looked here and more widely but cannot find anything on point. This is NOT important but I would like to fix a small problem that I cannot track down and it is irritating me.

I have a checkbox which works fine until I go into the xs media size of Bootstrap 3 display. I can do a quick fix warning not to use this in xs (this is a very rough proof-of-concept site and I have a million important things to do).

Using Chrome DevTools I have tried highlighting various bits and bobs but found nothing. So

1) I have looked for hidden, disabled and readonly: Is there any other CSS attribute that would cause a bit of code become unclickable?

2) (and I apologise in advance as I know this is a go-do-the-work-yourself point) when I am hunting for these attributes should I be looking at the checkbox code and expanding out? In DevTools the "Elements" panel has the CSS panel next to it and I am "filtering" on the above attributes. Question: If I select the checkbox would that show the influences on it or do I have to keep going up through the DOM looking at all the enclosing layers (I think I have to).

The code is NOT relevant to the question I am asking but ...

      <div class="box box-info box-solid collapsed-box" id="randomDayBox">
        <div class="box-header with-border">
          <!-- first span was visible-xs second span hidden xs -->
          <h3 class="box-title"><span class="">Rnd. days</span> <span class="">Random days</span>
          </h3>
          <div class="box-tools pull-right">
            <button class="btn btn-box-tool" type="button" data-widget="collapse"><i class="fa fa-plus"></i>
            </button>
          </div>
        </div>
        <div class="box-body">
          <div class="row ">
            <div class="col-xs-12  ">
              <div class="checkbox" >
                <label>
                  <input type="checkbox" name="randomDay" id="randomDayCheck" value="1" class=""> Use random days?
                </label>
              </div>
            </div>
            <div class=" col-xs-12 dimNoTickDays">

enter image description here The checkbox on the left does not work at "xs" size while the one on the right does and both work fine from "sm" size upwards.

There is jQuery code floating around and the whole build of AdminLTE 2.4 (which is not perfect!) I could list this all but all I am after is what could possibly make a checkbox uncheckable and a little guidance on the CSS tool in DevTools.

Grateful for any help available.




how to get the values of multiple JSON arrays using checkboxes?if i select the multiple checkboxes once at a time,im geting 1st json value

html and js

<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" >
    <link href="https://fonts.googleapis.com/css?family=Josefin+Sans&display=swap" rel="stylesheet">
    <title>Vendor Regestration</title>
</head>
<body>
<link href="https://fonts.googleapis.com/css?family=Josefin+Sans&display=swap" rel="stylesheet">
<div class="container">
<!-- <button class="btn btn-default" onclick="getallcategory();">click</button> -->
    <ul class="nav nav-tabs" id="myTab" role="tablist">
  <li class="nav-item">
    <a class="nav-link active" id="phone-tab" data-toggle="tab" href="#phone" role="tab" aria-controls="phone" aria-selected="true">Phone Verification</a>
  </li>
  <li class="nav-item">
    <a class="nav-link" id="info-tab" data-toggle="tab" href="#info" role="tab" aria-controls="info" aria-selected="false">Seller Information</a>
  </li>
  <li class="nav-item">
    <a class="nav-link" id="tax-tab" data-toggle="tab" href="#tax" role="tab" aria-controls="tax" aria-selected="false">Tax details</a>
  </li>
  <li class="nav-item">
    <a class="nav-link" id="seller-tab" data-toggle="tab" href="#seller" role="tab" aria-controls="seller" aria-selected="false">Select items to Sell</a>
  </li>
    <li class="nav-item">
    <a class="nav-link" id="interview-tab" data-toggle="tab" href="#interview" role="tab" aria-controls="interview" aria-selected="false">Interview</a>
  </li>
  <li class="nav-item">
    <a class="nav-link" id="dashboard-tab" data-toggle="tab" href="#dashboard" role="tab" aria-controls="dashboard" aria-selected="false">Dashboard</a>
  </li>
</ul>
<div class="tab-content" id="myTabContent">
  <div class="tab-pane fade show active" id="phone" role="tabpanel" aria-labelledby="phone-tab">
        <div class="container">
                <h1 class="text-center"><span style="color:#eb34db">Verify Mobile Number</span></h1><br><br>
                <div class="form-group form-inline justify-content-center">
    <label for="mobno"><p class="text-dark">Enter the mobile number</label>
    <input type="text" class="form-control" id="mobno" aria-describedby="nm"style="width: 300px; height: 30px;">
     <button type="submit" class="btn btn-primary my-1">Send SMS</button>
    <small id="nm" class="form-text text-muted">We'll send a verification code to this number</small>
  </div>
        </div>  
  </div>
  <div class="tab-pane fade" id="info" role="tabpanel" aria-labelledby="info-tab">
        <div class="container">
            <h1 class="text-warning text-center">Tell us about your business</h1><br><br>
            <form justify-content-center>
  <div class="form-group">
    <label for="sname">Store Name</label>
    <input type="text" class="form-control" id="sname" style="width: 400px;">
  </div>
  <div class="form-group">
    <label for="pc">Select Product Category</label>
    <select class="form-control" id="pc" style="width: 400px;">
      <option selected>Choose Primary Category</option>
    </select>
    </div>
    <h4 class="text-secondary ">Enter your Address</h4>
  <div class="form-group">
    <label for="pc">Pincode</label>
    <input type="text" class="form-control" id="pc" style="width: 400px;">
  </div>
  <div class="form-group">
    <label for="ad1">Addrress Line 1(Required)</label>
    <input type="text" class="form-control" id="ad1" style="width: 400px;">
  </div>
  <div class="form-group">
    <label for="ad2">Address Line 2</label>
    <input type="text" class="form-control" id="ad2" style="width: 400px;">
  </div>
  <div class="form-group">
    <label for="ct">City</label>
    <input type="text" class="form-control" id="ct" style="width: 400px;">
  </div>
  <div class="form-group">
    <label for="st">Select Your State</label>
    <select class="form-control" id="st" style="width: 400px;">
      <option selected>Choose State</option>
    </select>
    </div>
    <div class="form-check">
  <input class="form-check-input" type="checkbox" value="" id="ac1">
  <label class="form-check-label" for="ac1">
    aabbaaaa Services
  </label>
</div><br>
<button type="button" class="btn btn-primary" style="width: 300px">Next</button>
</form>
        </div>
  </div>
  <div class="tab-pane fade" id="tax" role="tabpanel" aria-labelledby="tax-tab">
    <div class="container">
        <h3 class="text-dark"> Update Your Tax details</h3><br>
        <h5 class="text-gray-dark">Do You Have GST Number?</h5>
        <div class="form-check">
  <input class="form-check-input" type="radio" name="yes" id="yes" value="Yes">
  <label class="form-check-label" for="yes">
    Yes
  </label>
  <br>
    <input class="form-check-input" type="radio" name="no" id="no" value="no">
  <label class="form-check-label" for="no">
    No
  </label>
</div><br>
<button type="button"class="btn btn-outline-warning" style="width: 300px;">Continue</button>
    </div>
  </div>
  <div class="tab-pane fade" id="seller" role="tabpanel" aria-labelledby="seller-tab">
    <div class="container">
    <h3 class="text-dark"> Choose categories, You wish to sell</h3><br>
      <div class="form-group form-inline text-center">
    <label for="select_category">Select Category</label>&emsp;
<select class="custom-select" id="select_category" style="width: 500px;" onchange="listcatcb();">
    <option selected></option>
  </select>
  <!-- &emsp;<button class="btn btn-outline-success" onclick="listcatcb();">Submit</button> -->
    </div>
<div class="container" id="cats">
  <div class="form-check" id="catrbs">
  </div>
  <button class="btn btn-outline-secondary" onclick="nextcats();">Click Next!</button>
</div>
</div>
</div>

   <div class="tab-pane fade pt-4" id="interview" roll="tabpanel" aria-labelledby="interview-tab">
    <div class="container">
        <h5 class="text-gray-dark ">Where do You get Products from?</h5>
        <div class="row">
            <div class="col-lg-6 col-md-6 col-12">
                <div class="form-check">
  <input class="form-check-input" type="checkbox" value="iman" id="iman">
  <label class="form-check-label" for="iman">
    I manufacture them
  </label>      
            </div>
        </div>
        <div class="col-lg-6 col-md-6 col-12">
                <div class="form-check">
  <input class="form-check-input" type="checkbox" value="imans" id="imans">
  <label class="form-check-label" for="imans">
    I sell manufactured from me
  </label>      
            </div>
            </div>
        </div>
        <div class="row">
            <div class="col-lg-6 col-md-6 col-12">
                <div class="form-check">
  <input class="form-check-input" type="checkbox" value="ires" id="ires">
  <label class="form-check-label" for="ires">
    I resell product that I buy
  </label>      
            </div>
            </div>
            <div class="col-lg-6 col-md-6 col-12">
                <div class="form-check">
  <input class="form-check-input" type="checkbox" value="imprt" id="imprt">
  <label class="form-check-label" for="imprt">
    I import them
  </label>      
            </div>
            </div>
        </div>
    <br><br>
    <div class="row">
      <div class="col-lg-6 col-md-6 col-12">
        <div class="form-group">
    <label for="atn">What is your annual turnover?</label>
    <select class="form-control" id="atn" style="width: 400px;">
      <option selected>Select an option</option>
    </select>
  </div>
      </div>
      <div class="col-lg-6 col-md-6 col-12">
                <div class="form-group">
    <label for="nop">How many products do you sell?</label>
    <select class="form-control" id="nop" style="width: 400px;">
      <option selected>Select an option</option>
    </select>
  </div>
      </div>
    </div>
    <div>
      <h5 class="text-gray-dark ">Do You sell in other websites?</h5>
    <div class="row">
  <div class="form-check form-check-inline">
  <input class="form-check-input" type="radio" name="y" id="y" value="y">
  <label class="form-check-label" for="y">Yes</label>
</div>
<div class="form-check form-check-inline">
  <input class="form-check-input" type="radio" name="n" id="n" value="n">
  <label class="form-check-label" for="n">No</label>
</div>
    </div>
  </div>
    </div>
   </div>
  <div class="tab-pane fade" id="dashboard" role="tabpanel" aria-labelledby="dashboard-tab">
    <div class="container">
        <h5 class="text-gray-dark pt-4">You're almost there to become a vendor with aabbaaaa</h5>
            <div class="jumbotron">
                <h3 class="text-gray-dark">1. Create Your aabbaaaa listings</h3>
                <p style="text-indent: 2em;">List the Products You wish to sell on aabbaa</p>
                <p class="text-dark"><b>Start selling in these categories:</b><br>Kitchen, Home, Consumer Electronics, Office Products</p>
                <div class="text-right">
                <button class="btn btn-outline-dark" id="startlisting">Start Listing</button>
            </div>
                <a href="#" style="text-decoration: none;">Edit Categories</a>

            </div>
            <div class="jumbotron">
               <div class="dropdown">
                <h3 class="text-gray-dark dropdown-toggle btn" id="sr" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" style="text-decoration: none;">2. Set Shipping rates</h3>
                <div class="dropdown-menu" aria-labelledby="sr">
                </div>
            </div>
                <p style="text-indent: 2em;">Set the shopping rate of the product for buyers</p>
                <div class="text-right">
                <button class="btn btn-light">Set rates</button>
            </div>
            <p class="text-gray">Set Your shipping rates</p>
            </div>
            <div class="jumbotron">
                <h3 class="text-gray-dark">3. Enter Bank details</h3>
                <form class="form-inline">
                     <label for="bn">Enter Name</label>
                         <input type="text" class="form-control" id="bn" placeholder="Name as on bank documents" style="width: 225px;">
                         <label for="selacc">Which type account you have</label>
                        <select class="custom-select my-1 mr-sm-2" id="selacc" >
                            <option selected>--Select your account type--</option>
                    </select>
                </form>
                <form class="form-inline">
                     <label for="acn">Account Number</label>
                    <input type="text" class="form-control" id="acn" placeholder="Upto 34 Charecters" style="width: 225px;">
                     <label for="racn"> Re-enter Account Number</label>
                    <input type="text" class="form-control" id="racn"  style="width: 225px;">

                </form><br>
                <label for="ifc">IFSC code</label>
                    <input type="text" class="form-control" id="ifc" placeholder="Example ABCD0123456" style="width: 225px;">

                <div class="text-right">
                    <button class="btn btn-light">Save</button> 
                </div>
            </div>
            <div class="jumbotron">
                <h3 class="text-gray-dark">4. Enter Tax details</h3>
                    <p style="text-indent: 2em;">Update Your tax Details</p>
                    <form class="form-inline">
                     <label for="pan">PAN Number</label>
                    <input type="text" class="form-control" id="pan"  style="width: 225px;">
                     <label for="gstn"> Provisional GSTIN</label>
                    <input type="gstn" class="form-control" id="gstn"  style="width: 225px;">

                </form>
                <div class="text-right">
                    <button class="btn btn-light">Save</button> 
                </div>
            </div>
            <div class="jumbotron">
                <h3 class="text-gray-dark">5. Product Tax Code</h3>
                <p style="text-indent: 2em;">PTC (Product Tax Code) are codes which are mapped to GST rates notified by the Govt.</p>

                <div class="form-group" style="position: relative;">
    <label for="pt"><p class="text-dark"><b>Default PTC</b></p></label>
    <input type="text" class="form-control" id="pt" style="width: 400px;">
  </div>
                <div class="form-group form-check">
    <input type="checkbox" class="form-check-input" id="aptc">
    <label class="form-check-label" for="aptc">I've reviewed to agree Aabbaaaa's <a href="#" style="text-decoration: none;">Tax Calculation Methodology</a></label>
  </div>
  <button class="btn btn-light">Save</button>
  <p><a href="#" style="text-decoration: none;">View all Product Tax Codes</a><br><a href="#" style="text-decoration: none;">Learn more about PTC</a></p>

            </div>
            <div class="jumbotron">
                <h3 class="text-gray-dark">6. Digital Image Signature</h3>
                <p style="text-indent: 2em;">Upload a scan copy of your signature which will be used on the invoices sent to customers.</p>
                <div class="row">
                    <div class="col-lg-6 col-md-6 col-12">
                        <label for="sin">Upload Your Signature</label>
                    <input type="file" class="form-control" id="sin"  style="width: 225px;">
                    </div>
                    <div class="col-lg-6 col-md-6 col-12">
                        <h5 class="text-gray-dark"><b>What to upload?</b></h5>
                        <ul>
                            <li style="style="text-indent: 2em;>Sign on a whhite Paper, scan the signature and upload the image</li>
                            <li style="style="text-indent: 2em;>Signature should be legible and in focus</li>
                            <li style="style="text-indent: 2em;>Only upload JPEG or JPG image format</li>
                            <li style="style="text-indent: 2em;>Image size should not exceed 2mb</li>
                        </ul>       
                    </div>
                </div>
            </div>
            <div class="text-center">
                <button class="btn btn-warning">Launch Your Business</button>
            </div>
    </div>
  </div>
</div>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js" integrity="sha384-wfSDF2E50Y2D1uUdj0O3uMBJnjuUD4Ih7YwaYd1iqfktj0Uod8GCExl3Og8ifwB6" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js"></script>
    <script>

   var selcat;
    document.getElementById("startlisting").onclick = function () {
        location.href = "plf.html";
    }
 getallcategory();
      function getallcategory()
{
var link='allcat.json';
$.post(link).done(function(data)
{
data2=JSON.stringify(data);
var obj=jQuery.parseJSON(data2);
for (var i = 0; i < obj.length; i++) 
{
  $("#select_category").append('<option value="' +obj[i].name+'">' +obj[i].name+ '</option> ')
}
});
}

function listcatcb()
{
   selcat=document.getElementById("select_category").value;
  var link='allcat.json';
$.post(link).done(function(data)
{
data2=JSON.stringify(data);
var obj=jQuery.parseJSON(data2);
for (var i = 0; i < obj.length; i++) 
{
  if (obj[i].name==selcat) 
  {
for (var j = 0; j < obj.length; j++) 
{
    // console.log(obj[i].siblings[j].name);
  $("#catrbs").append('<input class="form-check-input catcbs" type="checkbox" id="'+obj[i].siblings[j].name+'" value="'+obj[i].siblings[j].name+'"><label class="form-check-label" for="'+obj[i].siblings[j].name+'">'
    +obj[i].siblings[j].name+
  '</label><br/>')   
 }   
 } 
}

}); 
}

function nextcats()
{
  var link='allcat.json';


  // $(function(){
  //     var val = [];
  //       $('.catcbs:checked').each(function(i){
  //         val[i] = $(this).val();
  //     console.log(val[i]);
  //       });
  //     });
var checkedValue =  $('.catcbs:checked').val();;
  // console.log(checkedValue);
 $.post(link).done(function(data)
{
data2=JSON.stringify(data);
var obj=jQuery.parseJSON(data2);

for (var i = 0; i < obj.length; i++) 
{
  if (obj[i].name==selcat) 
  {
for (var j = 0; j < obj.length; j++) 
{

  if (obj[i].siblings[j].name==checkedValue) 
  {
 for (var k = 0; k < obj.length; k++) 
{
    console.log(obj[i].siblings[j].siblings[k].name);
  // $("#catrbs").append('<input class="form-check-input catcbs" type="checkbox" id="'+obj[i].siblings[j].siblings[k].name+'" value="'+obj[i].siblings[j].siblings[k].name+'"><label class="form-check-label" for="'+obj[i].siblings[j].siblings[k].name+'">'
  //   +obj[i].siblings[j].siblings[k].name+
  // '</label><br/>')   
 }   
 } 
}
}
}
});  
  }

$(document).ready(function () {
      $.ajax({
   url:"jsoncategory.txt",
   method:"POST",
   success:function(data)
   {
var cat=data;
var ks=[];
ks = cat.split("\n");
for(i=0;i<ks.length;i++)
{
$("#pc").append('<option value="' +ks[i]+'">' +ks[i]+ '</option> ')
}
},
   error:function(data){
          console.log(data);
        }
  })
      })
       </script>
</body>
</html>

JSON

[{
    "id": "47",
    "name": "Women",
    "parent": "0",
    "status": "Enabled",
    "itemcount": 44,
    "siblings": [{
        "id": "87",
        "name": "Personal Care Appliances",
        "parent": "47",
        "status": "Enabled",
        "itemcount": 2,
        "siblings": [{
            "id": "88",
            "name": "Hair Dryers",
            "parent": "87",
            "status": "Enabled",
            "itemcount": 2,
            "siblings": []
        }]
    }, {
        "id": "127",
        "name": "Jewellary",
        "parent": "47",
        "status": "Enabled",
        "itemcount": 41,
        "siblings": [{
            "id": "128",
            "name": "Artificial Jewellary",
            "parent": "127",
            "status": "Enabled",
            "itemcount": 41,
            "siblings": []
        }]
    }]
}, {
    "id": "51",
    "name": "Home furniture",
    "parent": "0",
    "status": "Enabled",
    "itemcount": 380,
    "siblings": [{
        "id": "59",
        "name": "Furniture",
        "parent": "51",
        "status": "Enabled",
        "itemcount": 119,
        "siblings": [{
            "id": "93",
            "name": "Chairs",
            "parent": "59",
            "status": "Enabled",
            "itemcount": 14,
            "siblings": []
        }, {
            "id": "94",
            "name": "Swing",
            "parent": "59",
            "status": "Enabled",
            "itemcount": 9,
            "siblings": []
        }, {
            "id": "109",
            "name": "Beds",
            "parent": "59",
            "status": "Enabled",
            "itemcount": 36,
            "siblings": []
        }, {
            "id": "110",
            "name": "Tables",
            "parent": "59",
            "status": "Enabled",
            "itemcount": 7,
            "siblings": []
        }, {
            "id": "111",
            "name": "Wadrobes",
            "parent": "59",
            "status": "Enabled",
            "itemcount": 44,
            "siblings": []
        }, {
            "id": "112",
            "name": "TV Units & Cabinets",
            "parent": "59",
            "status": "Enabled",
            "itemcount": 7,
            "siblings": []
        }]
    }, {
        "id": "70",
        "name": "Home Decor",
        "parent": "51",
        "status": "Enabled",
        "itemcount": 245,
        "siblings": [{
            "id": "71",
            "name": "Wall Clock",
            "parent": "70",
            "status": "Enabled",
            "itemcount": 245,
            "siblings": []
        }]
    }, {
        "id": "91",
        "name": "Home Lighting",
        "parent": "51",
        "status": "Enabled",
        "itemcount": 5,
        "siblings": [{
            "id": "92",
            "name": "Emergency Lights",
            "parent": "91",
            "status": "Enabled",
            "itemcount": 5,
            "siblings": []
        }]
    }, {
        "id": "123",
        "name": "Kitchen Storage",
        "parent": "51",
        "status": "Enabled",
        "itemcount": 13,
        "siblings": [{
            "id": "124",
            "name": "Water Bottles",
            "parent": "123",
            "status": "Enabled",
            "itemcount": 13,
            "siblings": []
        }]
    }]
}, {
    "id": "57",
    "name": "TVs & Appliances",
    "parent": "0",
    "status": "Enabled",
    "itemcount": 150,
    "siblings": [{
        "id": "58",
        "name": "Television",
        "parent": "57",
        "status": "Enabled",
        "itemcount": 10,
        "siblings": [{
            "id": "72",
            "name": "HD Ready TV",
            "parent": "58",
            "status": "Enabled",
            "itemcount": 1,
            "siblings": []
        }, {
            "id": "73",
            "name": "Full HD TV",
            "parent": "58",
            "status": "Enabled",
            "itemcount": 2,
            "siblings": []
        }, {
            "id": "74",
            "name": "Android TV",
            "parent": "58",
            "status": "Enabled",
            "itemcount": 0,
            "siblings": []
        }, {
            "id": "75",
            "name": "Smart TV",
            "parent": "58",
            "status": "Enabled",
            "itemcount": 2,
            "siblings": []
        }, {
            "id": "76",
            "name": "Smart 4K Ultra HD TV",
            "parent": "58",
            "status": "Enabled",
            "itemcount": 5,
            "siblings": []
        }]
    }, {
        "id": "68",
        "name": "Refrigerators",
        "parent": "57",
        "status": "Enabled",
        "itemcount": 55,
        "siblings": [{
            "id": "69",
            "name": "Double Door",
            "parent": "68",
            "status": "Enabled",
            "itemcount": 23,
            "siblings": []
        }, {
            "id": "77",
            "name": "Single Door",
            "parent": "68",
            "status": "Enabled",
            "itemcount": 24,
            "siblings": []
        }, {
            "id": "104",
            "name": "Deep Freezer",
            "parent": "68",
            "status": "Enabled",
            "itemcount": 8,
            "siblings": []
        }]
    }, {
        "id": "78",
        "name": "Kitchen Appliances",
        "parent": "57",
        "status": "Enabled",
        "itemcount": 14,
        "siblings": [{
            "id": "79",
            "name": "Microwave Oven",
            "parent": "78",
            "status": "Enabled",
            "itemcount": 6,
            "siblings": []
        }, {
            "id": "82",
            "name": "Oven Toaster Griller",
            "parent": "78",
            "status": "Enabled",
            "itemcount": 2,
            "siblings": []
        }, {
            "id": "83",
            "name": "Electric Kettle",
            "parent": "78",
            "status": "Enabled",
            "itemcount": 3,
            "siblings": []
        }, {
            "id": "84",
            "name": "Hand Blender",
            "parent": "78",
            "status": "Enabled",
            "itemcount": 4,
            "siblings": []
        }, {
            "id": "85",
            "name": "Sandwich Maker",
            "parent": "78",
            "status": "Enabled",
            "itemcount": 1,
            "siblings": []
        }, {
            "id": "86",
            "name": "Pop Up Toaster",
            "parent": "78",
            "status": "Enabled",
            "itemcount": 1,
            "siblings": []
        }]
    }, {
        "id": "80",
        "name": "Small Home Appliances",
        "parent": "57",
        "status": "Enabled",
        "itemcount": 38,
        "siblings": [{
            "id": "81",
            "name": "Fans",
            "parent": "80",
            "status": "Enabled",
            "itemcount": 17,
            "siblings": []
        }, {
            "id": "89",
            "name": "Iron",
            "parent": "80",
            "status": "Enabled",
            "itemcount": 5,
            "siblings": []
        }, {
            "id": "90",
            "name": "Room Heaters",
            "parent": "80",
            "status": "Enabled",
            "itemcount": 3,
            "siblings": []
        }, {
            "id": "125",
            "name": "Landline Phones",
            "parent": "80",
            "status": "Enabled",
            "itemcount": 10,
            "siblings": []
        }]
    }, {
        "id": "101",
        "name": "Washing Machine ",
        "parent": "57",
        "status": "Enabled",
        "itemcount": 33,
        "siblings": [{
            "id": "102",
            "name": "Fully Automatic Front Load",
            "parent": "101",
            "status": "Enabled",
            "itemcount": 5,
            "siblings": []
        }, {
            "id": "103",
            "name": "Fully Automatic Top Load",
            "parent": "101",
            "status": "Enabled",
            "itemcount": 14,
            "siblings": []
        }, {
            "id": "122",
            "name": "Semi Automatic Top Load",
            "parent": "101",
            "status": "Enabled",
            "itemcount": 14,
            "siblings": []
        }]
    }]
}, {
    "id": "95",
    "name": "Sports,Books & More",
    "parent": "0",
    "status": "Enabled",
    "itemcount": 50,
    "siblings": [{
        "id": "96",
        "name": "Stationary",
        "parent": "95",
        "status": "Enabled",
        "itemcount": 17,
        "siblings": [{
            "id": "97",
            "name": "Calculators",
            "parent": "96",
            "status": "Enabled",
            "itemcount": 17,
            "siblings": []
        }]
    }, {
        "id": "113",
        "name": "Car,bike Accessories",
        "parent": "95",
        "status": "Enabled",
        "itemcount": 33,
        "siblings": [{
            "id": "116",
            "name": "Helmets & Riding Gears",
            "parent": "113",
            "status": "Enabled",
            "itemcount": 33,
            "siblings": []
        }]
    }]
}, {
    "id": "98",
    "name": "Electronics",
    "parent": "0",
    "status": "Enabled",
    "itemcount": 65,
    "siblings": [{
        "id": "99",
        "name": "Computer Peripherals",
        "parent": "98",
        "status": "Enabled",
        "itemcount": 11,
        "siblings": [{
            "id": "100",
            "name": "Printers & Ink Cartridges",
            "parent": "99",
            "status": "Enabled",
            "itemcount": 11,
            "siblings": []
        }]
    }, {
        "id": "105",
        "name": "Gaming & Accessories",
        "parent": "98",
        "status": "Enabled",
        "itemcount": 37,
        "siblings": []
    }, {
        "id": "106",
        "name": "Laptops",
        "parent": "98",
        "status": "Enabled",
        "itemcount": 48,
        "siblings": [{
            "id": "107",
            "name": "Gaming Laptops",
            "parent": "106",
            "status": "Enabled",
            "itemcount": 48,
            "siblings": []
        }]
    }]
}, {
    "id": "117",
    "name": "Men",
    "parent": "0",
    "status": "Enabled",
    "itemcount": 6,
    "siblings": [{
        "id": "118",
        "name": "Footwear",
        "parent": "117",
        "status": "Enabled",
        "itemcount": 6,
        "siblings": [{
            "id": "119",
            "name": "Sports Shoes",
            "parent": "118",
            "status": "Enabled",
            "itemcount": 3,
            "siblings": []
        }, {
            "id": "120",
            "name": "Sandals & Floaters",
            "parent": "118",
            "status": "Enabled",
            "itemcount": 2,
            "siblings": []
        }, {
            "id": "121",
            "name": "Casual Shoes",
            "parent": "118",
            "status": "Enabled",
            "itemcount": 1,
            "siblings": []
        }]
    }]
}]

here in this code if i select the 2 checkbox once at a time means i'm getting output of only first JSON value... if i uncheck one means im getting its respective values... i mean for example if i select women from category then im getting 2 checkboxes as 1.personal care appliances and 2.jewellery. if i select multiple checkboxes once at the time means im getting only hair dryers(the value within personal care appliances) but im not getting artificial jewellery(value within jewellery) if i select single at a time means im getting appropriate result please help me out with this error... ive stucked here i beg you... along with that im getting

Uncaught TypeError: Cannot read property 'name' of undefined at Object <anonymous> (regpage.html:345)
    at i (jquery.min.js:2)
    at Object.fireWith [as resolveWith] (jquery.min.js:2)
    at y (jquery.min.js:4)
    at XMLHttpRequest.c (jquery.min.js:4)" this errror too... but it seems that it is not a major problem



Need to create autocomplete with master and multiselect checkbox

Problem 1-I have created autocomplete with multiselect checkbox but not able to check all the checkbox on click of some other checkbox which is not part of that autocomplete-multiselect-checkbox.

Problem 2:- whenever selection of checkbox of autocomplete-multiselect-checkbox need to populate some other autocomplete-multiselect-checkbox dynamically .

Example:Region and Country both are autocomplete-multiselect-checkbox Region A is having -(Country)1,2,3 Region B is having -(Country)4,5,6

if Region B checkbox is check then in Country autocomplete it should show 4,5,6 with checkbox.

For Problem 1: below is the HTML:

<input id="multiUsers" class="col-lg-8 multiselect-element w3-input inline" type="text" placeholder="search"></input>

below is the JS:

 var userData = [
     "ActionScript",
     "AppleScript",
     "Asp",
     "BASIC",
     "C++",
     "Clojure",
     "COBOL",
     "ColdFusion"
];
function split(val) {
    return val.split(/,\s*/);
}
function bindUsersAutoComplete(ele, options) {
    var text = ele.val();
    text = text == null || text == undefined ? "" : text;
    $(ele).autocomplete(options).data("ui-autocomplete")._renderItem = function (ul, item) {
    var checked = (text.indexOf(item.label + ', ') > -1 ? 'checked' : '');
    return $("<li></li>")
      .data("ui-autocomplete-item", item)
      .append('<a href="javascript:;"><input type="checkbox" class="checkBoxClass"' + checked + '/>' + item.label + '</a>')
      .appendTo(ul);
    };
}

$(function () {
  var $this;
  var multiSelectOptions = {
      minLength: 0,
      source: function (request, response) {
            response($.map(userData, function (item) {
            return {
                label: item
            }
        }));
      },
    select: function (event, ui) {
        var text = $this.val();
        text = text == null || text == undefined ? "" : text;
        var checked = (text.indexOf(ui.item.value + ', ') > -1 ? 'checked' : '');
        if (checked == 'checked') {
          this.value = this.value.replace(ui.item.value + ', ', '')
        }
         else {
          var terms = split(this.value);
          // remove the current input
          terms.pop();
          // add the selected item
          terms.push(ui.item.value);
          // add placeholder to get the comma-and-space at the end
          terms.push("");
          this.value = terms.join(", ");
        }           
        return false; 
    }
}

  $(document).find('#multiUsers').on('keydown', function () {
      bindUsersAutoComplete($this, multiSelectOptions);
    $($this).autocomplete("search");
    }).on('focus', function () {
        $this = $(this);
        bindUsersAutoComplete($this, multiSelectOptions);
        $($this).autocomplete("search");
    }) 
  })



Uncheck Checkbox when i use display "none" on some rows

Hei guys, I am trying to change my Check All Button to only check the rows that are visible. Unfortunately i am not seeing how i can address just the visible rows. I tried something like this, but i didnt work out.

$("#checkAll").click(function(){
    if(!x){
        if($(".check").is("visible")){
        $(':checkbox').each(function(){ this.checked = true; 

        });}

        x=true;}

    else{
        $(':checkbox').each(function(){ this.checked = false; });
        x= false;
        }});

Thats how i filter my table.

function abtFilter() {
      // Declare variables
      var input, filter, table, tr, td, i, txtValue;
      input = document.getElementById("searchbar");
      filter = input.value.toUpperCase();
      table = document.getElementById("notfallTable");
      tr = table.getElementsByTagName("tr");
      // Loop through all table rows, and hide those who don't match the search query
      for (i = 0; i < tr.length; i++) {
        td = tr[i].getElementsByTagName("td")[3];
        if (td) {
          txtValue = td.textContent || td.innerText;
          if (txtValue.toUpperCase().indexOf(filter) > -1) {
            tr[i].style.display = "";
          } else {
            tr[i].style.display = "none";
            $("")
          }
        }
      }
    }

and this is how the table looks like.

        items.push("<td class='numbers' contenteditable>"+val.Nummer+"</td>");
        items.push("<td contenteditable>"+val.Typ+"</td>");
        items.push("<td contenteditable>"+val.Vorname+"</td>");
        items.push("<td contenteditable>"+val.Nachname+"</td>");
        items.push("<td contenteditable>"+val.Abteilung+"</td>");

        items.push("<td class='check'><label><input type='checkbox'>"+""+"</input></label></td>");

        items.push("</tr>");

Greetings Elfdow




mercredi 29 janvier 2020

How to add dynamic checkbox from database

I'm trying this first time and I'm confused. I have two tables TblEmployee and tblHobby. In tblEmployee I have a Hobby column. I'm trying to add checkbox for this Hobby column from tblHobby.

In tblHobby I have two columns Id and HobbyName. I'm confused as to how to get data fron other table in database - please suggest a solution

This method is the one to fetch the hobby entries:

private void PopulateHobbies(Hobby hby)
{
    using (SqlConnection con = new SqlConnection(ConnectionString))
    {
        using (SqlCommand cmd = new SqlCommand())
        {
            cmd.CommandText = "select * from tblHobby";
            cmd.Connection = con;

            con.Open();

            using (SqlDataReader rdr = cmd.ExecuteReader())
            {
                 while (rdr.Read())
                 {
                     ListItem item = new ListItem();
                     item.Text = rdr["HobbyName"].ToString();
                     item.Value = rdr["Id"].ToString();
                     item.Selected = Convert.ToBoolean(rdr["IsSelected"]);
                 }
             }

             con.Close();
         }
     }
}

This us my AddEmployee method:

public void AddEmployee(Employee emp)
{
    using (SqlConnection con = new SqlConnection(ConnectionString))
    {
        SqlCommand cmd = new SqlCommand("spaddEmployee", con);
        cmd.CommandType = CommandType.StoredProcedure;

        cmd.Parameters.AddWithValue("@FirstName", emp.FirstName);
        cmd.Parameters.AddWithValue("@LastName", emp.LastName);
        cmd.Parameters.AddWithValue("@Gender", emp.Gender);
        cmd.Parameters.AddWithValue("@DOB", Convert.ToDateTime(emp.DOB));
        cmd.Parameters.AddWithValue("@Hobby",emp.Hobby);
        cmd.Parameters.AddWithValue("@Photo", emp.Photo);
        cmd.Parameters.AddWithValue("@City", emp.City);

        con.Open();
        cmd.ExecuteNonQuery();
        con.Close();
    }
}

And this is my Create page

<div class="form-group">
    @Html.LabelFor(model => model.Hobby, htmlAttributes: new { @class = "control-label col-md-2" })
    <div class="col-md-10">
        @*@Html.CheckBoxFor(Model => Model.Hobby, htmlAttributes: new { @class = "control-label col-md-2" })*@
    </div>
    @Html.ValidationMessageFor(model => model.Hobby, "", new { @class = "text-danger" })
</div>



how to store the selected checkbox value in an array list in android studio?

I have check box options in Alert Dialog(android studio).I want the checked value to be stored in array list so that i can use the values in the next activity.So how do i create a array list for the same and store the selected values in it.




Update sql record by checkbox in php

I have a problem to update sql record by checkbox in php.My problem is when I press the update button,all can show me update previous info record,but only in the checkbox unable to show me the previous record. Below is my coding:

Checkbox coding:

     <div class="form-group col-lg-6">
                    <label class="control-label col-lg-4">Pricing<span style="color:red;">&nbsp;</span></label>
                    <div class="col-lg-8">
                    <input type="checkbox" name="rm_option" id="rm_option" value="1"><strong> RM </strong></input>&nbsp;&nbsp;&nbsp;
                    <input type="checkbox" name="point_option" id="point_option" value="1"><strong> Full Point </strong></input>&nbsp;&nbsp;&nbsp;
                    <input type="checkbox" name="partial_option" id="partial_option" value="1"><strong> Partial Point + RM </strong></input>
                    </div>
                    </div>

update function coding:

         else if($action == 'update') {
        $id = isset($_POST['filter_id']) ? $_POST['filter_id'] : "";
        $id_promotion_categories = isset($_POST['id_promotion_categories']) ? $_POST['id_promotion_categories'] : "";
        $promotion_title = isset($_POST['promotion_title']) ? $_POST['promotion_title'] : "";
        $promotion_description = isset($_POST['promotion_description']) ? $_POST['promotion_description'] : "";
        $reservation = isset($_POST['reservation']) ? $_POST['reservation'] : "";
        $feature = isset($_POST['feature']) ? $_POST['feature'] : "";
        $discount_percentage = isset($_POST['discount_percentage']) ? $_POST['discount_percentage'] : "";
        $promotion_price_before = isset($_POST['promotion_price_before']) ? $_POST['promotion_price_before'] : "";
        $promotion_price_before = isset($_POST['promotion_price_before']) ? $_POST['promotion_price_before'] : "";

        $rm = isset($_POST['rm']) ? $_POST['rm'] : "";
        $point = isset($_POST['point']) ? $_POST['point'] : "";
        $partial_point = isset($_POST['point_rm_point']) ? $_POST['point_rm_point'] : "";
        $partial_rm = isset($_POST['point_rm_rm']) ? $_POST['point_rm_rm'] : "";

        $rm_option  = isset($_POST['rm_option ']) ? $_POST['rm_option '] : "";
        $point_option  = isset($_POST['point_option ']) ? $_POST['point_option '] : "";
        $partial_option  = isset($_POST['partial_option ']) ? $_POST['partial_option '] : "";


     $query = "UPDATE " . $table ." SET id_promotion_categories = '" . $id_promotion_categories . "', promotion_title = '".$promotion_title."', promotion_description = '".$promotion_description."', reservation = '".$reservation."',rm = '".$rm."',point = '".$point."',point_rm_point = '".$partial_point."',point_rm_rm = '".$partial_rm."',rm_option = '".$rm_option."',point_option = '".$point_option."',partial_option = '".$partial_option."', feature = '".$feature."' where id='" . $id . "'";

    $arr_treatment = db_conn_update($query);

    if ($arr_treatment) {

            $result_arr['msg'] = 'Update Successful';
        } else {
            $result_arr['msg'] = 'Error in processing data. Please try again later.';
        }
        $result_arr = special_char_display_arr($result_arr);
        $json = json_encode($result_arr);
        print($json);

     } else if($action == 'edit'){
        $id = isset($_POST['id']) ? $_POST['id'] : "";
        $sql = 'SELECT *  FROM promotion_list WHERE id = ' . $id;
        $result_arr['sql'] = $sql;
        $result_arr = get_tbl_row($sql); 
        //$result_arr['treatment_category_name'] = get_tbl_val('treatment_category_list', 'id', 'name', $result_arr['category']);
        $result_arr = special_char_display_arr($result_arr);
        $json = json_encode($result_arr);
        print($json);

Below is my output, the red box and the arrow means it unable to show me the previous record to update when I press the update button:

Output

Hope someone can guide me how to solve it. Thanks.




Trying to parse a CheckboxTreeview from ttkwidgets and get the checkbox status of all the items in the tree

I've been trying to parse a checkbox treeview to return a dictionary with the item's ID as the key and the checkbox status as the value as "checked", "unchecked" and "tristate". However, I tried to sort the items by using CheckboxTreview.get_checked(). I don't know if i'm using it wrong or this is just a flaw from the package but it only returns the checked item from the highest level ('' as the parent).

from tkinter import *
from tkinter import ttk
from ttkwidgets import CheckboxTreeview

def parse_Tree(tree, parent):

    children = list(tree.get_children(parent))
    checkedList = tree.get_checked()
    itemDic = {}
    #print(checkedList)

    for item in children:
        if tree.get_children(item) == () and item in checkedList:
            itemDic[item] = "checked"
        elif tree.get_children(item) != () and item in checkedList:
            itemDic[item] = "checked"
            itemDic.update(parse_Tree(tree, item))
        elif tree.get_children(item) != () and item not in checkedList:
            for boxStatus in parse_Tree(tree, item).values():
                if boxStatus == "checked" or boxStatus == "tristate":
                    itemDic[item] = "tristate"
                else:
                    itemDic[item] = "unchecked"
                    itemDic.update(parse_Tree(tree,item))
        else:
            itemDic[item] = "unchecked"

    return itemDic

def listTreeview(textFile):

    list = []
    file = open(textFile, "r")
    treeview = file.read().split("\n")
    file.close()
    for item in treeview:
        list += [item.split(",")]
    root = Tk()
    master = ''
    level = []
    tree = CheckboxTreeview(root)
    for index,i in enumerate(list):
        indent = 0

        while i[0][indent] == ' ': indent += 1

        if indent%4:
            print("wrong indentation")
            break
        else:
            i[0] = i[0].replace(' ','')

        level.append(int(indent/4))

        if len(level)==1:
            tree.insert(master,'end',i[0], text = i[0])
        elif level[index]-level[index-1] == 1:
            master = list[index - 1][0]
            tree.insert(master, 'end', i[0], text=i[0])
        elif level[index]-level[index-1] < 0:
            prev = index-1
            while level[index] != level[prev]:
                prev -= 1
            master = tree.parent(list[prev][0])
            tree.insert(master,'end',i[0], text = i[0])
        elif level[index] - level[index - 1] > 1:
            print('wrong indentation')
        else: #level hasnt change
            tree.insert(master, 'end', i[0], text=i[0])
        if i[1] == '1':
            tree.change_state(i[0], "checked")


    tree.expand_all()
    dic = parse_Tree(tree,'')
    print(dic)
    tree.pack()
    root.mainloop()

listTreeview("Treeview.txt")

I parsed the following text file to work with, the indentation indicates the level and the last number indicates if it is checked or not.In this situation for exemple, item4.1.1 should appear as item4.1.1:"checked" but it doesn't...

Is there any other way to go through a checkbox treeview and get the state of each items?

item0,1
item1,0
    item1.1,0
    item1.2,0
item2,0
    item2.1,1
    item2.2,0
        item2.2.1,1
        item2.2.2,0
            item2.2.2.1,0
    item2.3,0
        item2.3.1,1
item3,1
item4,0
    item4.1,1
    item4.2,0
    item4.2.1,0



Passing checkbox value from .html page to .js file (not mvc)

I need to pass a checkbox value from my .html page to a seperate .js file. the .js file doesn't share a window, I cant use jQuery, and its not MVC so no tempdata or controllers etc. Any ideas? Thanks

if(checkboxid == true){
  function myfunction(){
    //do stuff
  }
}
and in a separate file + window..
<input type="checkbox" id="checkboxid" name="checkboxid" checked>
<input type="hidden" id="checkboxid" name="checkboxid" value="false">



VBA - Filtering list with userform checkbox

I am currently trying to create a userform that will help to filter my list (link) based on what fruits are talked about in which documents.

For example, looking at my userform below, I would like to be able to click on apples and then click ' Find Documents' in order to filter the excel list to only the documents that talk about apples (543, 45, 723, 44, 86, 95, 7, 33, 64).

The only way I could figure out how to do was to manually add other columns (D and E), and add 1's / 0's depending on whether or not the fruit were talked about in the document.

I have then created a macro to filter only the documents containing apples based on the 1's and 0's from column D:

        Sub FilterApple()
            ActiveSheet.Range("B2:F21").AutoFilter Field:=4, Criteria1:="1"
        End Sub

Then, within the code for the userform,

        Private Sub CommandButton1_Click()
        If CheckBoxApples = True Then Call FilterApples
        End Sub

I created another macro when clicking on the 'Find Documents' button, to call this Filter Apples function if this is true. If it is checked, then the macro works and it sorts by which documents talk about apples.

The problem is I do not know where to go from here (if I want to sort by multiple or even just a different item) I figured there was also probably an easier way to do this as opposed to my method so I figured I would reach out for help.

I am currently unable to attach pictures as this is my first time on here, so if you have any additional questions please let me know.




Checkbox selection triggered from another function

I'm trying to make a code that when I click DIV, Checkbox marks me and the second time I click, it marks

The color changes and the DIV clicks. But automatic selection and unchecking for Checkbox do not work

I have error:

Uncaught TypeError: selectedValue.prop is not a function at HTMLDivElement.document.getElementById.onclick

I have template GSP with this code:

<div id="${item.key}">
    <input id="Position_${item.key}" type="checkbox" />  ${index + 1}. ${item.key} 
</div>

And script in the same file:

<script>
    document.getElementById('${item.key}').onclick = function () {
        let selectedValue = document.getElementById('Position_${item.key}');

        if (this.style.backgroundColor == 'lightgreen') {
            changeColor(this, 'white');
            selectedValue.prop('checked', false);
        } else {
            changeColor(this, 'lightgreen');
            selectedValue.prop('checked', true);
        }
    };
</script>



Pagination with multiple checkbox and pagination in laravel

I have a modal in the page for create new role in my system and this modal list all permissions to the role. My problem is this: This modal have a table with multiple checkboxes and pagination, but when I go to page 2, 3, 4... The checkboxes lost the selection. I try any things to resolve this problem, but i cant. Modal checkbox list

The cod of pagination

 $(document).on('click', '.pagination a', function (e) {
        e.preventDefault();

        var url = $(this).attr('href');

        $('#modal-content').load(url + " #content-result");
    });

The modal

<div class="modal fade" id="add-permissions" tabindex="-1" role="dialog" aria-labelledby="Adicionar permissões"
    aria-hidden="true">
    <div class="modal-dialog modal-dialog-scrollable modal-lg" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <h5><b>Adicionar Permissões</b></h5>
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">&times;</span>
                </button>
            </div>
            <div class="modal-body">
                <div class="row">
                    <div class="col-md-12">
                        <input type="text" name="modal-search" class="form-control" id="search-1"
                            placeholder="Procurar pelo nome">
                    </div>
                </div>

                <hr>

                <div id="modal-content">
                    <div id="content-result">
                        <div class="row">
                            <div class="col-md-12">
                                <table class="table table-bordered table-sm" id="table-search-1">
                                    <thead>
                                        <tr>
                                            <th>Nome</th>
                                            <th>Rótulo</th>
                                            <th>Selecionar</th>
                                        </tr>
                                    </thead>

                                    <tbody>
                                        @forelse ($permissions as $key => $permission)
                                        <tr>
                                            <td></td>
                                            <td></td>
                                            <td>
                                                <input type="checkbox" class="teste-add" name="addPermissions[]" id="" value="">
                                            </td>
                                        </tr>
                                        @empty
                                        <tr>
                                            <td colspan="2" class="text-center"><b>Nenhuma permissão encontrada!</b>
                                            </td>
                                        </tr>
                                        @endforelse
                                    </tbody>
                                </table>
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-md-12">
                                <p>{!! $permissions->links() !!}</p>
                            </div>
                        </div>
                    </div>
                </div>
            </div>

            <div class="modal-footer justify-content-between">
                <div class="row">
                    <div class="col-md-12">
                        <button type="button" class="btn btn-primary" data-dismiss="modal">Ok</button>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>



Is there a HTML code for a monthly calendar with checkboxes for everyday?

I am looking for some help. I have a leadpages website and I am looking to add a live calendar to my website which has a checkbox on each day for my clients to tick whether they did their daily habit.

Leadpages hasn’t got a calendar function but has a custom HTML widget button which I was hoping to use to insert this calendar. I just need help with what the code would be to make something like this - would love some help with this!

Please contact me or reply if you can help me with this!

I will attach a photo of what I would like or similar! 👇

Calendar example




mardi 28 janvier 2020

Using GetElementsByClassName to check checkbox values and if the checkbox is checked programatically

The task is to write to a string whether a checkbox has been checked out of a series of 27 checkboxes with the same class name of "GEMS_0".

When I access elements through console it works.

document.getElementById(document.getElementsByClassName("GEMS_0")[0].id).value

returns "moved"

document.getElementById(document.getElementsByClassName("GEMS_0")[0].id).value

returns false.

When I do it programmatically, by calling getGEMSValue(0), it works for the first element and then returns null for the value of the second element when it should be "filled with wonder". I tried changing to "filled-with-wonder" but that didn't change anything.

Here is the code for accessing the elements programmatically:

  function getGEMSValue(num) {
    let return_string = "";
    let checkboxes = document.getElementsByClassName("GEMS_" + num.toString());
    console.log(checkboxes);
    for (var i = 0; i < checkboxes.length; i++) {
      console.log(checkboxes[i].id);
      console.log(document.getElementById(checkboxes[i].id));
      let value = document.getElementById(checkboxes[i].id).value
      if (document.getElementById(checkboxes[i].id).checked) {
        return_string += value + ";";
      } else {
        return_string += "false;";
      }
    }
    //remove semicolon at end
    return_string = return_string.slice(0,-1);
    return return_string;
  }

This is the HTML being accessed.

      <p align="center">How would you describe this video's overall emotion? You may select multiple options.</p>
      <!-- 9 emotions per row, 5 rows -->
      <div>
        <div class="form-check form-check-inline">
          <input class="form-check-input GEMS_0" type="checkbox" id="inlineCheckbox1" value="moved">
          <label class="form-check-label" for="inlineCheckbox1">moved</label>
        </div>
        <div class="form-check form-check-inline">
          <input class="form-check-input GEMS_0" type="checkbox" id="inlineCheckbox2" value="filled with wonder">
          <label class="form-check-label GEMS_0" for="inlineCheckbox2">filled with wonder</label>
        </div>
        <div class="form-check form-check-inline">
          <input class="form-check-input GEMS_0" type="checkbox" id="inlineCheckbox3" value="allured">
          <label class="form-check-label GEMS_0" for="inlineCheckbox3">allured</label>
        </div>
        <div class="form-check form-check-inline">
          <input class="form-check-input GEMS_0" type="checkbox" id="inlineCheckbox4" value="fascinated">
          <label class="form-check-label" for="inlineCheckbox4">fascinated</label>
        </div>
        <div class="form-check form-check-inline">
          <input class="form-check-input GEMS_0" type="checkbox" id="inlineCheckbox5" value="overwhelmed">
          <label class="form-check-label" for="inlineCheckbox5">overwhelmed</label>
        </div>
        <div class="form-check form-check-inline">
          <input class="form-check-input GEMS_0" type="checkbox" id="inlineCheckbox6" value="feeling of transcendence">
          <label class="form-check-label" for="inlineCheckbox6">feeling of transcendence</label>
        </div>
        <div class="form-check form-check-inline">
          <input class="form-check-input GEMS_0" type="checkbox" id="inlineCheckbox7" value="serene">
          <label class="form-check-label" for="inlineCheckbox7">serene</label>
        </div>
        <div class="form-check form-check-inline">
          <input class="form-check-input GEMS_0" type="checkbox" id="inlineCheckbox8" value="calm">
          <label class="form-check-label" for="inlineCheckbox8">calm</label>
        </div>
        <div class="form-check form-check-inline">
          <input class="form-check-input GEMS_0" type="checkbox" id="inlineCheckbox9" value="soothed">
          <label class="form-check-label" for="inlineCheckbox9">soothed</label>
        </div>
        <br />
        <div class="form-check form-check-inline">
          <input class="form-check-input GEMS_0" type="checkbox" id="inlineCheckbox10" value="tender">
          <label class="form-check-label" for="inlineCheckbox10">tender</label>
        </div>
        <div class="form-check form-check-inline">
          <input class="form-check-input GEMS_0" type="checkbox" id="inlineCheckbox11" value="affectionate">
          <label class="form-check-label" for="inlineCheckbox11">affectionate</label>
        </div>
        <div class="form-check form-check-inline">
          <input class="form-check-input GEMS_0" type="checkbox" id="inlineCheckbox12" value="mellow">
          <label class="form-check-label" for="inlineCheckbox12">mellow</label>
        </div>
        <div class="form-check form-check-inline">
          <input class="form-check-input GEMS_0" type="checkbox" id="inlineCheckbox13" value="nostalgic">
          <label class="form-check-label" for="inlineCheckbox13">nostalgic</label>
        </div>
        <div class="form-check form-check-inline">
          <input class="form-check-input GEMS_0" type="checkbox" id="inlineCheckbox14" value="sentimental">
          <label class="form-check-label" for="inlineCheckbox14">sentimental</label>
        </div>
        <div class="form-check form-check-inline">
          <input class="form-check-input GEMS_0" type="checkbox" id="inlineCheckbox15" value="dreamy">
          <label class="form-check-label" for="inlineCheckbox15">dreamy</label>
        </div>
        <div class="form-check form-check-inline">
          <input class="form-check-input GEMS_0" type="checkbox" id="inlineCheckbox16" value="strong">
          <label class="form-check-label" for="inlineCheckbox16">strong</label>
        </div>
        <div class="form-check form-check-inline">
          <input class="form-check-input GEMS_0" type="checkbox" id="inlineCheckbox17" value="energetic">
          <label class="form-check-label" for="inlineCheckbox17">energetic</label>
        </div>
        <div class="form-check form-check-inline">
          <input class="form-check-input GEMS_0" type="checkbox" id="inlineCheckbox18" value="triumphant">
          <label class="form-check-label" for="inlineCheckbox18">triumphant</label>
        </div>
        <br />
        <div class="form-check form-check-inline">
          <input class="form-check-input GEMS_0" type="checkbox" id="inlineCheckbox19" value="animated">
          <label class="form-check-label" for="inlineCheckbox19">animated</label>
        </div>
        <div class="form-check form-check-inline">
          <input class="form-check-input GEMS_0" type="checkbox" id="inlineCheckbox20" value="bouncy">
          <label class="form-check-label" for="inlineCheckbox20">bouncy</label>
        </div>
        <div class="form-check form-check-inline">
          <input class="form-check-input GEMS_0" type="checkbox" id="inlineCheckbox21" value="joyful">
          <label class="form-check-label" for="inlineCheckbox21">joyful</label>
        </div>
        <div class="form-check form-check-inline">
          <input class="form-check-input GEMS_0" type="checkbox" id="inlineCheckbox22" value="sad">
          <label class="form-check-label" for="inlineCheckbox22">sad</label>
        </div>
        <div class="form-check form-check-inline">
          <input class="form-check-input GEMS_0" type="checkbox" id="inlineCheckbox23" value="tearful">
          <label class="form-check-label" for="inlineCheckbox23">tearful</label>
        </div>
        <div class="form-check form-check-inline">
          <input class="form-check-input GEMS_0" type="checkbox" id="inlineCheckbox24" value="blue">
          <label class="form-check-label" for="inlineCheckbox24">blue</label>
        </div>
        <div class="form-check form-check-inline">
          <input class="form-check-input GEMS_0" type="checkbox" id="inlineCheckbox25" value="tense">
          <label class="form-check-label" for="inlineCheckbox25">tense</label>
        </div>
        <div class="form-check form-check-inline">
          <input class="form-check-input GEMS_0" type="checkbox" id="inlineCheckbox26" value="agitated">
          <label class="form-check-label" for="inlineCheckbox26">agitated</label>
        </div>
        <div class="form-check form-check-inline">
          <input class="form-check-input GEMS_0" type="checkbox" id="inlineCheckbox27" value="nervous">
          <label class="form-check-label" for="inlineCheckbox27">nervous</label>
        </div>
        <br />
      </div>