mardi 19 octobre 2021

How show checkbox checked data-img on list

I have this field

<input class="red-heart-checkbox " name="photo[]" type="checkbox" value="<?php echo $id; ?>" id="<?php echo $id; ?>" data-img="<?php echo $imageURL; ?>"/>

And I would like to make a list of image with url image from the data-img checked but I only have values with this code :

<script>
            $(function() {
        var masterCheck = $("#masterCheck");
        var listCheckItems = $("#devel-generate-content-form :checkbox");

        masterCheck.on("click", function() {
          var isMasterChecked = $(this).is(":checked");
          listCheckItems.prop("checked", isMasterChecked);
          getSelectedItems();
        });

        listCheckItems.on("change", function() {
          var totalItems = listCheckItems.length;
          var checkedItems = listCheckItems.filter(":checked").length;

          if (totalItems == checkedItems) {
            masterCheck.prop("indeterminate", false);
            masterCheck.prop("checked", true);
          }
          else if (checkedItems > 0 && checkedItems < totalItems) {
            masterCheck.prop("indeterminate", true);
          }
          else {
            masterCheck.prop("indeterminate", false);
            masterCheck.prop("checked", false);
          }
          getSelectedItems();
        });

        function getSelectedItems() {
          var getCheckedValues = [];
          getCheckedValues = [];
            
          listCheckItems.filter(":checked").each(function() {
            getCheckedValues.push($(this).val());
          });
            
          $("#selected-values").html(JSON.stringify(getCheckedValues));
        }
      });
        </script>
        

My result is on :

<li class="list-group-item" id="selected-values"></li>

And looks like this :

result of script

Is it possible to have url image instead of the value , or use the result with de database to have url image ?

Thanks a lot !




Como enviar un valor +1 a un campo numerico de sql por medio de la activacion de un checkbox en un documento aspx

Estoy llevando a cabo una aplicacion(aspx document) de encuestas de satisfaccion, y estoy trabajando con controladores de tipo checkbox (esto para permitir cambiar el icono antes y dsp de presionarlo)

Me gustaria conocer una manera de incrementar (+1) el campo correspondiente en la tabla de sql, al checkbox presionado.




how to return blank values with checked checkbox

How to return blank values from datagridview columns using checkbox, who is checked. So how it is in both pictures, I want to filter blank rows without date and it should work as filter as blank.

That checkbox gets data from database.

I tried some if statements in my sql procedure.

if @INNOT_CLOSED_CARDS is not null
        set @WHERE = @WHERE + 'AND EXISTS (select hosp_ID from D3_HOSPITALIZATION
            where isnull(CLOSE_DATE,'''') = '''')'

Or something like this.

if @INNOT_CLOSED_CARDS = 1
    BEGIN
        set @WHERE = @WHERE + ' AND (CLOSE_DATE is null)'
    END ELSE if @INNOT_CLOSED_CARDS = 0
    BEGIN
        set @WHERE = @WHERE + ' AND (CLOSE_DATE is not null)'
    END

Well, it does nothing.

enter image description here

enter image description here




CheckBox Data to ListBox (VBNet)

the problem with my code is that when i initially select a particular checkbox it works well and displays selected item in listbox, but when selected again it creates another entry within the listbox and when i remove it i have to uncheck the same checkbox the times it has been displayed in the listbox when i click the btnSubmit.

Can someone tell me what's wrong with the code, thank you so much

Private Sub btnSubmit_Click(sender As Object, e As EventArgs) Handles btnSubmit.Click
    If CheckBox1.Checked Then
        ListBox1.Items.Add(CheckBox1.Text)
    Else
        ListBox1.Items.Remove(CheckBox1.Text)
    End If
    If CheckBox2.Checked Then
        ListBox1.Items.Add(CheckBox2.Text)
    Else
        ListBox1.Items.Remove(CheckBox2.Text)
    End If
    If CheckBox3.Checked Then
        ListBox1.Items.Add(CheckBox3.Text)
    Else
        ListBox1.Items.Remove(CheckBox3.Text)
    End If
    If CheckBox4.Checked Then
        ListBox1.Items.Add(CheckBox4.Text)
    Else
        ListBox1.Items.Remove(CheckBox4.Text)
    End If
    If CheckBox5.Checked Then
        ListBox1.Items.Add(CheckBox5.Text)
    Else
        ListBox1.Items.Remove(CheckBox5.Text)
    End If
    If CheckBox6.Checked Then
        ListBox1.Items.Add(CheckBox6.Text)
    Else
        ListBox1.Items.Remove(CheckBox6.Text)
    End If
End Sub



lundi 18 octobre 2021

Change data in MongoDB from admin page

Hi, there!

I have a school managing system CMS with Node.js, MongoDB and Mongoose. This site has no registration so everyone can apply to courses. The person applying give personal data push submit and the data given goes to the admin page.

My goal is the find a way to keep track where is the student process at. The data is being rendered in a table and that table has a column where you can change the status: 'approved', 'denied', and 'in progress'. The model schema for it is set to 'default: 'in progress'.

What I want to do is to put three checkboxes in the admin table and if I check for example 'denied' the data is changed and save in the database as well from the default 'in progress' to 'denied'.

I tried to find a solution in Mongoose documentation but nothing came up and I am very new to Node.

Can any of suggest a method how to approach this problem?

Thank you!




Checkbox checked on load and input box filled when a value present

I have created a sandbox::

https://codesandbox.io/s/sweet-agnesi-qbf7g?file=/src/components/HelloWorld.vue

So my basic query is let say I have an array of object present as:

  let sampleArrayOfObject = [{
    Item: "ACC",
    Price: 12,
  },
  {
    Item: "BCC",
    Price: 50,
  },
  {
    Item: "ECC",
    Price: 21,
  }]

I have input field of type checkbox and text,

in checkbox let say I have ACC, BCC, CCC, DCC, ECC.

Let's say when sampleArrayOfObject matches with the checkbox field, ACC,BCC,CCC,DCC,ECC all the matching value present in sampleArrayOfObject should be checked and input field of type should have Price as value.

When checkbox is clicked, input field of type text should be visible where we can input the value.

So we should be able to remove the present value or change the price value and all those values should be store in newItem variable (detail on this variable present in codesandbox) on click of submit.

I tried but I am stuck, please let me know if anyone needs any further information or need any further clearance.




Handling multiple checkboxes in edit form angular

I have multiple checkboxes on edit form whose selected values I am sending to backend and retrieving database values on page load and showing checkbox checked for retrieved values.

template code

 <div class="col-lg-12">
                <div class="form-group">
                  <label class="w-100">Type of events <b style="color: red">*</b></label>
                  <div class="pretty_wrapper">
                    <div class="pretty p-default"  *ngFor="let event of EventTypes index as i">
                      <input type="checkbox" 
                      [name] = "'EventType_'+event.id" 
                      [value]="event.id" 
                      (change)="onCheckboxChange($event)"
                      [attr.checked]="isChecked(event.id)"
                      />
                      <div class="state d-flex"  >
                        <label> </label>
                      </div>
                    </div>
                  </div>
                  <div class="text-danger" *ngIf="submitted && eventArray.length === 0" >
                    Event type is required, select atleast one value.
                  </div>
                </div>
              </div>

component code

        ...
          selectedEventIds:any = [];
          public eventArray:any = [];
        ...
  ngOnInit() {
...
        if (results['status'] === true) {
                 
                    for (let event_type of results.data.event_type) {
                      this.selectedEventIds.push(event_type.event_type_id);
                    }
        }
        
        ...
}
          onSubmit() {
         for (let event_id of this.eventArray) {
              this.formData.append('event_type[]', event_id);
            }
            ...
        }
        
         onCheckboxChange(e) {
            if (e.target.checked) {
              this.eventArray.push(e.target.value);
            } else {
              const index =  this.eventArray.indexOf(e.target.value, 0);
              if (index > -1) {
                this.eventArray.splice(index, 1);
              }
            }
          }
    
    isChecked(eventId){
       return this.selectedEventIds.indexOf(eventId)>-1 ? true : null;
      }

Now above update code fails if database has values and user does not select any checkbox as it finds eventArray is empty. If I assign database values to eventArray in ngOnInit then onCheckboxChange event eventArray shows empty so evenif I deselect checked checkboxes then nothing change in eventArray in that event.

How I can manage those testcases in angular? Plese guide and help. Thanks in advance.