Dynamic URL on bootstrap modal
<p>I'm using Laravel for my web app.</p>

<p>On each of the rows of my "countries" table I have an "edit" button which opens up a modal and fills the textarea with the existing name of the country. This textarea can be edited and updated in the database.</p>

<p>This is the partial code of my modal:</p>

<pre><code>{!! Form::model($country, [
    'method' =&gt; 'PATCH',
    'url' =&gt; ['country', 'lblCountryId'],
    'class' =&gt; 'form-horizontal'
]) !!}

// some more code

// and the edit button for each row
&lt;td&gt;
   &lt;button type="submit" class="btn btn-primary btn-xs" 
         data-toggle="modal" data-target="#editModal"
         data-id=" {{ $item-&gt;id }}"
         data-name="{{ $item-&gt;name }}"&gt;
         &lt;i class="fa fa-pencil" aria-hidden="true"&gt;&lt;/i&gt;
   &lt;/button&gt;
&lt;/td&gt;
</code></pre>

<p>When the modal shows, I manupulate the value of the textfield with folloring JS:</p>

<pre><code>$(function () {
    $('#editModal').on("show.bs.modal", function (e) {
        $("#lblCountryId").html($(e.relatedTarget).data('id'));
        document.getElementById("txtCountryName").value = $(e.relatedTarget).data('name');
    });
});
</code></pre>

<p>With that same script I want to edit the URL to which the form is posting, but JS does not seem to like that.</p>

<p>Is there any way I can change the URL of the form dynamically according to which row I clicked on?</p>