

@model EForT.Models.PublisherModel
<div class="modal fade text-left" id="ChooseForexModal" tabindex="-1" role="dialog" aria-labelledby="ChooseForexModalLabel" aria-hidden="true">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <h5 class="modal-title" id="ChooseForexModalLabel">Choose Forex Account</h5>
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">&times;</span>
                </button>
            </div>
            <div class="modal-body">
                <input type="hidden" asp-for="EditSubscriber.Id" id="hdnId" />
                <fieldset class="form-group floating-label-form-group">
                    <label for="ChooseForexModalLabel">Forex Account: <i class="warning">*</i></label>
                    <select name="forexAccountList" class="form-control" asp-for="EditSubscriber.ForexAccount" id="ChooseSubForexAccount" onchange="handle_selection(this)" required>
                        <option value="" selected>Select</option>
                        @if (Model?.ListAvailableForexAccounts?.Count > 0)
                        {
                            for (int i = 0; i < Model.ListAvailableForexAccounts.Count; i++)
                            {
                                var forexAccount = Model.ListAvailableForexAccounts[i];

                                <option id="choiceForexID" value="@forexAccount.Id">@forexAccount.ForexId</option>
                            }

                            
                           
                            
                        }
                    </select>
                   
                </fieldset>

            </div>
            <div class="modal-footer">
                <button disabled id="btn-choose-forex" onclick="handle_submit()" class="btn btn-primary">Subscribe</button>
                <input id="close-modal" type="reset" class="btn btn-secondary" data-dismiss="modal" value="Close">
            </div>
        </div>
    </div>
</div>
<script>
    function handle_selection(event) {
        if (event.value > 0) {
            $("#btn-choose-forex").removeAttr("disabled");
        } else {
            $("#btn-choose-forex").attr("disabled", true);
        }

    }
    function handle_submit() {
        
        var e = document.getElementById("ChooseSubForexAccount");
        var strUser = e.options[e.selectedIndex].value;

        location.href = "HasUserPaid4Subscription?loginId=" + @Model.LoggedUserId + "&publisherId=" + @Model.EditPublisher.Id + "&forexId=" + strUser;
    }
    


   

</script>