Dynamically set value for asp-route-id using javascript without foreach loop
<p>I am working on an ASP.Net MVC 6 application. The default index view usually has links for Edit, Details and Delete inside the foreach loop like</p>

<pre><code>@foreach (var item in Model) {
        &lt;tr&gt;
            &lt;td&gt;@Html.DisplayFor(modelItem =&gt; item.FirstName)&lt;/td&gt;
            &lt;td&gt;@Html.DisplayFor(modelItem =&gt; item.LastName)&lt;/td&gt;
            &lt;td&gt;
                &lt;a asp-action="Edit" asp-route-id="@item.SpeakerId"&gt;Edit&lt;/a&gt; |
                &lt;a asp-action="Details" asp-route-id="@item.SpeakerId"&gt;Details&lt;/a&gt; |
                &lt;a asp-action="Delete" asp-route-id="@item.SpeakerId"&gt;Delete&lt;/a&gt;
            &lt;/td&gt;
        &lt;/tr&gt;
    }
</code></pre>

<p>My requirement is such that the links for View, Edit &amp; Delete should appear outside the table and the row should be selected using radio buttons column. </p>

<p>Is there any way to set the asp-route-id attribute dynamically using the onchange event of radiobutton?</p>

<p>I have tried something link this</p>

<pre><code>function radioSelected() {        
        var routeId = $('input[name="selectRecord"]:checked').val();
        var links = "&lt;a asp-action='Details' asp-route-id=" + routeId + "&gt;View Details&lt;/a&gt; | "
                    + "&lt;a asp-action='Edit' asp-route-id=" + routeId + "&gt;Edit&lt;/a&gt; | "
                    + "&lt;a asp-action='Delete' asp-route-id=" + routeId + "&gt;Delete&lt;/a&gt;";

        document.getElementById("actions").innerHTML = links;
    }
</code></pre>

<p>but the asp-route-id and asp-action attributes don't work this way.</p>