1
I have a Customer code = 3368. I made a function jquery that takes the code from Dropdown, which may be 1 or 3368 (only has two records there in the dropdown). It turns out that when I have in dropdown 1 the Customer is 3368 and if I change the dropdown to 3368 then the Customer goes to 1. This is the jquery I started to mount
$('#btnSalvar').click(function () {
var dropdown = $('#faturarPara').val();
var customerId = @Model.CustomerId;
alert('Drop2 é: ' + dropdown + ' e customer é: ' + customerId);
});
What intrigues me about all this is if I run another jquery in the dropdown change call, then it works 1 and 3368 and then 3368 and 3368. But then it doesn’t happen anymore. That’s the change
$(document).ready(function () {
$('#faturarPara').change(function () {
var idFaturarDrop = $(this).val();
var customerId = @Model.CustomerId;
alert('Customer é: ' + customerId + ' customer options = ' + idFaturarDrop);
});
});
I honestly don’t understand. The correct thing would be: In the dropdown I change (de->to) Resale->Final Client(3368 and 3368). From Final Client->Resale(3368 and 1)
This is the Dropdown
@Html.DropDownListFor(m => m.CustomerId, new SelectList(Model.Options, "CustomerId", "Description", Model.CustomerId), new { @id= "faturarPara" })
I don’t know if I understand, but what I need to do is compare the two ID’s, which I take in Dropdown(variable) with the model ID(fixed). I don’t know if getting the text would be the right one. I need his ID
– pnet
I need a little more context so I can help. But I think retrieving the value of the selected item would suffice 'var id = $('.Selected-item'). val();' E then you can compare the recovered id
– ScrapBench
I posted the Dropdown code. What I want to do is compare the past Ids.
– pnet
I updated the answer
– ScrapBench
Scrapbench, I’m taking a Undefined on this approach of yours.,
– pnet
Strange should not be recovering the value of select however if perbeci well the attribute is Customerid
– ScrapBench
My problem is not in the dropdown ID, this is correct. The whole question is in the customerId. It is changing and should not, in my view, only the drop ID should change. The other is fixed and still can not understand why
– pnet
By what variable you are transferring the customerId that is causing problem ?
– ScrapBench