Skip to content
Advertisement

How Can I call a dynamic index in function cshtml?

I have this function :

JavaScript

And this html’s tag:

JavaScript

My id is buildered with a foreach that pass value to variable:

JavaScript

My question is: Is correct Call this index in an other function in this way ?? :

JavaScript

thanks for feedback

Advertisement

Answer

It seems that you want to write some html and javascript code, relating to each item of a list.

In this case, I often prefer to directly write html and related javascript for event binding and code customization.

I supposing that method is your razor variable in your foreach, and methods is the enumerable variable to loop, you may would write this code for html

JavaScript

But if you want to write some common jQuery code for this set of radio buttons, I’ prefer to manage it with class selector rather than ID rules, as follow

JavaScript

Hope this, help you for better code management.

Br Andryx

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement