vendredi 2 novembre 2018

Selected Checkbox value(s) to a different page

Iam new to this stuff. But I want to send checked checkbox value(s) to different page. Iam illustrating what i desire with code below;

php_checkbox.php file

<!DOCTYPE html>
<html>
<head>
<title>Get Values of Multiple Checked Checkboxes</title>
<link rel="stylesheet" href="css/php_checkbox.css" />
</head>
<body>
<div class="container">
<div class="main">
<center>
<h2>PHP: Get Values of Multiple Checked Checkboxes</h2>
<form action="checkbox_value.php" method="post">
<label class="heading">Select Your Technical Exposure:</label><p>
<input type="checkbox" name="check_list[]" 
value="C/C++"><label>C/C++       </label> <p>
<input type="checkbox" name="check_list[]" value="Java">    
<label>Java</label> <p>
<input type="checkbox" name="check_list[]" value="PHP"><label>PHP</label><p>
<input type="checkbox" name="check_list[]" 
value="HTML/CSS"><label>HTML/CSS</label><p>
<input type="checkbox" name="check_list[]" 
value="UNIX/LINUX"><label>UNIX/LINUX</label><p>
<input type="submit" name="submit" Value="Submit"/>
<p>
</form>
</div>
</div>
</body>
</html>

checkbox_value.php file

<?php
if(isset($_POST['submit'])){
if(!empty($_POST['check_list'])) {
// Counting number of checked checkboxes.
$checked_count = count($_POST['check_list']);

foreach($_POST['check_list'] as $selected) {
echo "<p>".$selected ."</p>";}

for ($x = 1; $x <= $checked_count; $x++) {

?>


<!DOCTYPE html>
<html>
<head>
<style>
table, th, td {
border: 1px solid black;
border-collapse: collapse;
}
th, td {
padding: 5px;
text-align: left;    
}
</style>
</head>
<body>

<h2>Cell that spans two columns</h2>
<p>To make a cell span more than one column, use the colspan attribute.</p>

<table style="width:50%">
<tr>
<td>Technology</td>
<td><?php echo $selected; ?></td>
</tr>
</table>

<?php
} 
}
else{
}
}
?>

</body>
</html>

The above code work. The problem is when I select Java and PHP, I get PHP displayed in both tables. When I select 3 options, the last option get displayed in all tables. What I need is when I select e.g. PHP, JAVA, and UNIX/LINUX, the 3 options (PHP, JAVA, UNIX/LINUX) be displayed on the tables separately - PHP on the first table, Java on the second table and UNIX/LINUX on the third table. When I select only 2 (e.g. Java and PHP), I want Java on the first table and PHP on the second. Please help.




Other way to disable checkbox?

Besides the regular disabled property, is there any other way to "disable" a checkbox visually and functionally?

I'm just wondering if there's something like readonly for checkbox. I'm developing this module where a checkbox is disabled when either of the 2 unrelated conditions are met. I just want to keep it simple without writing some more codes and all.

Plan is, 1 condition triggers the disabled property and the other one triggers the "disabled2" property.




jeudi 1 novembre 2018

How to set checkbox setChecked true from Database

I have listview with Checkbox and TextView. when I checklist that checkbox than save it. I am succesful to save it to database.

but when I am going to another activty, after that when i am going back, the checkbox didn't setChecked true just like before I did it.

In my logic, when I have database from checkbox cheked.. the checkbox should setChecked true, and the oterwise if I don't have database from it, The Checkbox should setChecked false.

this is my code:

 public class StoreFilterAdapters  extends BaseAdapter {
    private Context context;
    private LayoutInflater inflater;
    private boolean isListView;
    private SparseBooleanArray mSelectedItemsIds;
    private DatabaseHandler databaseHandler = new DatabaseHandler();
    private List<MstStore> mItems;;
    private List<MstSelectedStore> mItemsSelected;
    private String strStateView, strValueCheck;
    boolean[] checkBoxState;
    String check;
    String idStore;

    public StoreFilterAdapters(Context context, List<MstStore> arrayList, String stateView, boolean isListView) {
        this.context        = context;
        this.mItems         = arrayList;
        this.strStateView   = stateView;
        this.isListView     = isListView;
        inflater            = LayoutInflater.from(context);
        mSelectedItemsIds   = new SparseBooleanArray();
    }

    @Override
    public int getCount() {
        return mItems.size();
    }

    @Override
    public Object getItem(int i) {
        return mItems.get(i);
    }

    public void setFilter(List<MstStore> storeList) {
        mItems = new ArrayList<>();
        mItems.addAll(storeList);
        notifyDataSetChanged();
    }

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

    @Override
    public View getView(final int i, View view, ViewGroup viewGroup) {
        ViewHolder viewHolder;
        final MstStore ObjStore = mItems.get(i);


        if (view == null) {
            viewHolder = new ViewHolder();
            view = inflater.inflate(R.layout.item_filter_merchant, viewGroup, false);
            viewHolder.label    = view.findViewById(R.id.storeName);
            viewHolder.checkBox = view.findViewById(R.id.checkbox_filter_merchant);
            view.setTag(viewHolder);
        } else viewHolder = (ViewHolder) view.getTag();

        mItemsSelected  = databaseHandler.getAllSelectedStore();
        if (mItemsSelected.size() > 0){
            Toast.makeText(context, "ada", Toast.LENGTH_SHORT).show();
            for (int ii = 0; ii < mItemsSelected.size(); ii++){
                viewHolder.checkBox.setChecked(truemSelectedItemsIds.get(ii));
            }

        }else {
            viewHolder.checkBox.setChecked(mSelectedItemsIds.get(i));
        }
        viewHolder.label.setText(ObjStore.getStoreName());
        viewHolder.checkBox.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                checkCheckBox(i, !mSelectedItemsIds.get(i));
            }
        });

        viewHolder.label.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                checkCheckBox(i, !mSelectedItemsIds.get(i));
            }
        });

        view.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                checkCheckBox(i, !mSelectedItemsIds.get(i));
            }
        });

        return view;
    }

    private class ViewHolder {
        private TextView label;
        private CheckBox checkBox;
    }

    public void removeSelection() {
        mSelectedItemsIds = new SparseBooleanArray();
        notifyDataSetChanged();
    }

    public void checkCheckBox(int position, boolean checked) {
        if (checked) {
            mSelectedItemsIds.put(position, true);
            check = mItems.get(position).getStoreID();

        } else {
            if (Build.VERSION.SDK_INT >= 28) {
                mSelectedItemsIds.removeAt(position);
            }else {
                mSelectedItemsIds.delete(position);
            }
        }
        notifyDataSetChanged();
    }

    /**
     * Return the selected Checkbox IDs
     **/
    public SparseBooleanArray getSelectedIds() {
        return mSelectedItemsIds;
    }

    public void getCheckedItems() {
        if (mSelectedItemsIds != null) {
            for (int i = 0; i < mItems.size(); i++) {
                if (mSelectedItemsIds.get(i)) {
                    MstStore objStore = (MstStore) getItem(i);
                    databaseHandler.addSelectedStore(new MstSelectedStore(objStore.getStoreID()));

                }
            }
        }
    }

    }

Please help me. Sorry for my bad english.




check box checked javascript

I am trying to set a value in a text box based on whether the checkbox is checked or not The function is attached to onclick of the checkbox This simple thing is not working :(

<div>
MyCheckbox
<input type="checkbox" id="Check1" name="FirstCkName" 
 onclick="testCheckbox(Check1,TextBx1)" />
 </div><br>

 <div>
  CheckBx Text Box
  <input id="TextBx1" name="CheckBxName"  type="text"  /> 
  </div><br>

<script>
function testCheckbox(oCheckbox,oTxtbox)
{

if (oCheckbox.checked == true)
{
    document.getElementById("oTxtbox").value=1;
}
else
{
    document.getElementById("oTxtbox").value="";
}
}
</script>

Link to JSfiddle https://jsfiddle.net/JS_learner/2750639m/30/




Unhide/Hide rows in excel with a form checkbox

I have a form created in excel which has rows [10:48] hidden and I want to make so that when you click a checkbox rows [10:48] are unhidden. I assigned a macro to the checkbox and using this formula:

Private Sub CheckBox45_Click()

  If CheckBox45 = True Then

  [10:48].EntireRow.Hidden = False

  Else: [10:48].EntireRow.Hidden = True

End If

End Sub

When I click the checkbox nothing happen, but when I unhide the rows and click the checkbox it hides the rows. Which makes me think that only one of the actions is working. Is there a way to fix this?

Thanks in advance for the help.

Don't know if this matters but the form checkbox is in column D row 6




Checkboxes not being checked programatically after user checks it once

I'm having an interesting problem I can't solve with a Vue app I'm working on. The behaviour I want (parent checkbox when (un)checked, (un)checks all child checkboxes) is there, but with a problem.

When you click a checkbox, that checkbox is ignored by parent checkboxes. This means that after clicking any child checkbox, clicking a parent checkbox has no effect on the previously clicked checkbox; it just keeps it's value.

Here's where it gets weird: I looked at the elements tab in safari, and it says the clicked box is changing values when the parent is (un)selected, but visually it is staying the same.

I know that the box is checked, since other parts of the app are doing what I expect, but I can't figure out why it will say a box has class="checked" checked="checked", but still be visually unchecked.

Is there something else that happens to a checkbox when you click it, that makes the way I check child checkboxes visually incorrect?

Relevant HTML:

<template>
<div v-for=“(foo, bar) in foobar” :key=bar>
<div class=“root”>
    <input id='checkbox' type="checkbox" class="checked" checked="checked" @click=“handleRootClick($event)">
</div>
<div class=“child 1”>
    <div v-for=“(foo, bar) in foobar” :key=bar>
        <div class=“child 1 header">
            <input id='checkbox' type="checkbox" class="checked" checked="checked" @click=“handleChild1Click($event)">
        </div>
        <div class=“child 1”>
            <div v-if=“foobar.length > 0">
                <div class=“child 2 header">
                    <input id='checkbox' type="checkbox" class="checked" checked="checked" @click=“handleChild2Click($event)">
                </div>
                <div class="resource-dropdown-contents">
                    <div v-for=“(foo, bar) in foobar” :key=bar>
                        <div class=“child 3 header">
                            <input id='checkbox' type="checkbox" class="checked" checked="checked" @click=“handleChild3Click($event)">
                        </div>
                        <div class="compute-dropdown-contents">
                            <div v-for=“(foo, bar) in foobar” :key=bar>
                                <div class=“child 4 header">
                                  <input id='checkbox' type="checkbox" class="checked" checked="checked" @click=“handleChild4Click($event)">
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

And here is the relevant typescript code:

public handleRootClick(e) {
    const root = e.currentTarget.parentElement.parentElement;
    const checkboxes = root.querySelectorAll('#checkbox');
    const isChecked = checkboxes[0].classList.contains('checked');

    if (isChecked) {
        // ensure all children are unchecked
        for (let i = 0; i < checkboxes.length; i++) {
            if (checkboxes[i].classList.contains('checked')) {
                checkboxes[i].classList.remove('checked');
                checkboxes[i].removeAttribute('checked');
            }
        }
    } else {
        // ensure all children are checked
        for (let i = 0; i < checkboxes.length; i++) {
            if (!checkboxes[i].classList.contains('checked')) {
                checkboxes[i].classList.add('checked');
                checkboxes[i].setAttribute('checked', 'checked');
            }
        }
    }
    e.stopPropagation();
}

The other handleChildxClick functions are very similar to the above function.




script and formula for timestamp when a check mark is filled

I saw this response (below) from a poster responding to a request for an automatic timestamp when a cell is filled out. I've added this script as a new project in Google Sheets. My question is, what is the formula to use in the cell where I want the timestamp??

function onEdit() {
var s = SpreadsheetApp.getActiveSheet();
if( s.getName() == "Sheet1" ) { //checks that we're on the correct sheet
var r = s.getActiveCell();
if( r.getColumn() == 4 ) { //checks the column
  var nextCell = r.offset(0, 1);
  if( nextCell.getValue() === '' ) //is empty?
    nextCell.setValue(new Date());
}
}
}

This code does what I understood from yours, which is: if something is edited on column D and column E is empty, add the current date to E.