$('input.editor-active', row).prop( 'checked' with variables

$('input.editor-active', row).prop( 'checked' with variables

Hildeb67Hildeb67 Posts: 67Questions: 19Answers: 1

I have this Code rows

var kalenderwoche = 'kw08';
            
$('input.editor-active', row).prop( 'checked',  data[kalenderwoche].Mo_mitbus == 1  );


This work perfect but with the variable "mitbusfahrt" does not work

var kalenderwoche = 'kw08';
var mitbusfahrt = '.Mo_mitbus';
            
$('input.editor-active', row).prop( 'checked',  data[kalenderwoche]mitbusfahrt == 1  );


can someone help me here?
Thanks and regards Christian

This question has an accepted answers - jump to answer

Answers

  • kthorngrenkthorngren Posts: 21,341Questions: 26Answers: 4,954
    edited February 2023 Answer ✓

    You will need to remove the . in '.Mo_mitbus' and place the variable in brackets, like this:

    var kalenderwoche = 'kw08';
    var mitbusfahrt = 'Mo_mitbus';
                 
    $('input.editor-active', row).prop( 'checked',  data[kalenderwoche][mitbusfahrt] == 1  );
    

    Kevin

  • Hildeb67Hildeb67 Posts: 67Questions: 19Answers: 1

    Thanks a lot works perfectly

Sign In or Register to comment.