We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
Starting in 2019, the Reporting control is no longer included in Essential Studio. If you're experiencing issues with the Syncfusion Reporting Platform, Report Viewer, Report Designer, or Report Writer, we recommend migrating to Bold Reports, our dedicated reporting platform.

Bold Reports offers a comprehensive suite of tools and features for all your reporting needs, and we will help you make a smooth transition from the discontinued control. Our support team at https://support.boldreports.com/ is here to assist you with any questions or difficulties you may encounter during the migration process.

We thank you for choosing Syncfusion and appreciate your understanding.

Derive one field name from another (dimensional filed name like name[8]

 name="weekday[8]" type="checkbox" value="21" class="weekday" checked="">
 name="timing[8]" type="text" id="name" value="11" size="45" />

 name="weekday[9]" type="checkbox" value="99" class="weekday" checked="">
 name="timing[9]" type="text" id="name" value="12" size="45" />

 name="weekday[10]" type="checkbox" value="77" class="weekday" checked="">
 name="timing[10]" type="text" id="name" value="13" size="45" />


I have above html code

  1. when checkbox for checkbox name="weekday[8]" is clicked, I want to check whether timing[8] is empty or not (we need to derive field name timing[8] from field name weekday[8]

  2. when timing[8] some value is entered , i want to name="weekday[8]" -> checked (we need to derive field name weekday[8] from timing[8]

we can find the name (jquery)

$('.weekday').click(function(){
var checkboxname=$(this).attr('name');

// we get checkbox clicked name=name[8]

console.log('checkbox name='+checkboxname);

})

we get name of field (checkbox is clicked) as name[8]

i want to derive field name timing[8]

i tried (jquery)

$('.weekday').click(function(){

var checkboxname=$(this).attr('name');
console.log('checkboxname='+checkboxname);// i got this correct 
weekday[8] in this case

var splitname=checkboxname.split('weekday');// seperated [8] ,  

console.log(splitname[0]+'  1='+splitname[1]); //splitname[1] will have [8]

//now want to form or generate value of variable mobile[8]

var n='mobile'+splitname[1];//the n will be  mobile[8]
console.log('n='+n);// ths will be mobile[8]

var inp=$('input[name="'+n+'"]').val();
console.log(' inp='+inp);// but no success
//here I want value of $('input[name=name[8]').val(); 

})

Please guide how i derive(using jquery)

filed name mobile[8] from field name[8]


2 Replies

VA Vikas Athavale December 31, 2022 03:50 PM UTC

this problem solved

html

name="weekday[8]" type="checkbox" value="21" class="weekday" checked="" data-id="8">
 name="timing[8]" type="text" id="name" value="11" size="45" data-id="8" />

 name="weekday[9]" type="checkbox" value="99" class="weekday" checked="" data-id="9">
 name="timing[9]" type="text" id="name" value="12" size="45" data-id="9" />

 name="weekday[10]" type="checkbox" value="77" class="weekday" checked="" data-id="10" >
 name="timing[10]" type="text" id="name" value="13" size="45" data-id="10"/>

script

<script>

  $(".weekday").click( function() {

 let id = $(this).data("id")

 console.log('weekday dataid='+id);// get data-id value of checkbox

  console.log('weekday dataid(attr) ='+$(this).attr("data-id"));

       let time = $(".timing[data-id="+id+"]")

console.log('time='+time);

if ($(this).is(":checked")) { // check box for weekday is checked

   $(time).focus()

}

  else

  {

  console.log(' unchedked '+time)

          $(time).text('');

  }

  });


$('.timing').blur(function() {


   let id = $(this).data("id")

    console.log('timing blur data-id='+id)

   let timing=$(".timing[data-id="+id+"]").val() ;;


  console.log('timing text ='+timing);   // display the text stored in timing

 let wk=".weekday[data-id="+id+"]";

 console.log("wk="+wk);

  let weekday = $(".weekday[data-id="+id+"]") // find timing input with same data-id value


// i am getting weekday as unefined

  console.log( 'timing blur weekday '+weekday ); //timing blur weekday [object Object]

  if (timing =='')   // text is blank

   {

     // $(weekday).prop('checked', true);// set checkbox checked

  $(wk).prop('checked',false) ;

   }

 else

 {

   $(wk).prop('checked',true) ;

 }

});

</script>



AM Arumugasami Murugesan Syncfusion Team January 3, 2023 05:46 AM UTC

Hi Vikas Athavale ,


Thanks for contacting Bold Report support.


We are glad to hear that you have found the solution. If you face any other issues, we suggest you to open a new ticket using your account. 

https://support.boldreports.com/create


Regards,

Arumugasami M


Loader.
Live Chat Icon For mobile
Up arrow icon