mercredi 3 janvier 2018

How to reference currect element inside its defaultChecked - React

I have a dynamic array a[1,3] I have 3 checkboxes which have name and value and I want to default check them based on the dynamic array a. I want to pass inside defaultCheck each current child's value.Is that possible? Something like defaultChecked={giveCheck(self.value} and be executed in the beginning so the checkboxes get their default check status

<input type="checkbox" name="a" value="1" />
<input type="checkbox" name="a" value="2" />
<input type="checkbox" name="a" value="3" />

giveCheck(value) {
if(a.indexOf(value)>=0){
return true;
}
return false;
}




Visio shape with Checkbox control

I've created a Shape, build from several sub shapes and want to change the shape fillcolor when the checkbox is checked.

This works when I'm within the "Edit Master Shape" dialogue, but not anymore when the shape is saved in the stencil and inserted on the drawing.

  • macro's are enabled
  • stencil is an .vssm file

Shape and master explorer

Visual basic code snippet




mardi 2 janvier 2018

Spring form checkboxes - Putting each 2 checkboxes in one row

I've been trying to put each 2 Spring Form checkboxes in a separate table row using bootstrap but I couldn't.
Here's my code:

<f:form action="/saveEvent" modelAttribute="event" method="post" id="eventForm">

...

        <div class="form-group">
            <label>Trainers</label><br>
            <f:checkboxes path="trainers" items="${trainersList}" 
                          element="div class='col-md-6 checkbox form-control' 
                          CssStyle='float:right'"
                          itemLabel="fullName" itemValue="id" delimiter=""/>
        </div>
</f:form>

And this is the result I am getting

Current result screenshot

And here's the generated HTML code

<div class="form-group">
    <label>Trainers</label><br>
    <div class="col-md-6 checkbox form-control" cssstyle="float:right">
    <input id="trainers1" name="trainers" type="checkbox" value="6" checked="checked">
    <label for="trainers1">Walid Mbarek</label>
  </div>
  <div class="col-md-6 checkbox form-control" cssstyle="float:right">
    <input id="trainers2" name="trainers" type="checkbox" value="7" checked="checked">
    <label for="trainers2">Bouraoui Chebili</label>
  </div>
  <div class="col-md-6 checkbox form-control" cssstyle="float:right">
    <input id="trainers3" name="trainers" type="checkbox" value="14">
    <label for="trainers3">Randy Ross</label>
  </div>
  <div class="col-md-6 checkbox form-control" cssstyle="float:right">
    <input id="trainers4" name="trainers" type="checkbox" value="17">
    <label for="trainers4">Mohamed Ali Thaier</label>
  </div>
  <div class="col-md-6 checkbox form-control" cssstyle="float:right">
    <input id="trainers5" name="trainers" type="checkbox" value="21" checked="checked">
    <label for="trainers5">Echrak Saidani</label>
  </div>
  <div class="col-md-6 checkbox form-control" cssstyle="float:right">
    <input id="trainers6" name="trainers" type="checkbox" value="25">
    <label for="trainers6">Marwen Chatti</label>
  </div><input type="hidden" name="_trainers" value="on"> </div>

I really like the way they look now, but the way I need them to display is a pair per row.

I also need the result to be in a table because I will have a search filter based on js that works only with tables




C# assign checked items of datagridview to array

enter image description here

I want to get the values next all to the checked CheckBox and save it into an array, maybe loop through all CheckBox that is checked and save the data next to it in an array

private void dataGridView1_CellValueChanged(object sender, DataGridViewCellEventArgs e)
    {           
        List<string> someList = new List<string>();
        var message = string.Join(Environment.NewLine, someList);
        foreach (DataGridViewRow row in this.dataGridView1.Rows)
        {
            var cell = row.Cells[e.ColumnIndex] as DataGridViewCheckBoxCell;

            if (Convert.ToBoolean(cell.Value) == true)
            {
                if (cell.State != DataGridViewElementStates.Selected)
                {
                    someList.Add(row.Cells[1].Value.ToString());
                }
            }
            else if (cell.State == DataGridViewElementStates.Selected)
            {
                someList.Add(row.Cells[1].Value.ToString());
            }
            message = string.Join(Environment.NewLine, someList);
        }
        MessageBox.Show(message);
    }

I've asked here before and someone gave this answer, but I want to save it now in an array. Thanks for all your effors




Flask issue with two forms and checkboxes

I am trying to create a form which will be used for marking comments to delete -using checkboxes. Here's a template

<form action = "" method='post'>
        
        
      </form>

Here is a function:

@app.route('/delete_comment', methods=['GET','POST'])
@login_required
@admin_required
def delete_comment():
    form_delete = DeleteCommentForm()
    if form_delete.do.data:
        if request.method == 'POST':
            comments = request.form.getlist('delete')
            print(comments)
   return redirect(url_for('index')

)

Right know I am trying to at least get a list of values of checkboxes to determine whether it is working.

If anyone of you have an idea what is not working, please help :)




JavaScript Refresh Page after 5 Seconds on Checked Checkbox

Is there any way to refresh a webpage every 5 seconds if checkbox is checked?

For example, if the checkbox is unchecked, nothing happens, but if it's checked, then the function refresh() will make the page refresh every 5 seconds afterwards.

Here is the code I have so far, but this isn't working for some reason.

HTML:

<input type="checkbox" id="autoRefresh" onclick="if(this.checked){refresh()}" checked>

JS:

function refresh() {
         setTimeout(function () { location.reload() }, 5000);
    }




Is it possible to set DefaultCheck with function? React

I have a component which get props a:[] b:[] values might be 1, 2, 3, 4

I have 8 checkboxes with name="a" and "b" with value="1" , "2","3" and "4" respectively

is it possible to set the defaultChecked with function? something like

<input name="a" type="checkbox" value="1" defaultChecked={this.checkIt.bind(this,name,value)} />

checkIt(this,name.value) {
if (this.props.name.indexOf(value)>=0)
{
   return true;
}
return false;
}