Answer the question
In order to leave comments, you need to log in
Selecting the value of only one select'a?
Hey! There are two selects in the form. When one appears, the second disappears. The user can only select the value of one select. Then, using ajax, the values are passed to the PHP handler. But the problem is that the value of the last select is always passed. How to fix it?
$('.reg').hide();
$('#yandexUA').change(function () {
$('#ua').toggle();
$('#ua [value="187"]').attr('selected', 'true');
$('#ru [value="225"]').attr('selected', 'false');
$('#ru').hide();
});
$('#yandexRU').change(function () {
$('#ru').toggle();
$('#ru [value="225"]').attr('selected', 'true');
$('#ua [value="187"]').attr('selected', 'false');
$('#ua').hide();
})
Answer the question
In order to leave comments, you need to log in
Thanks everyone. I did this - I remove the name and everything works)
Dates different ID? You can't use the same id on multiple elements on a page.
here you need a code that generates data for an AJAX request to the server. I suspect that your name attribute is the same for selects. Please also note that the visibility of the form element on the page does not affect whether data is sent from it to the server or not, the data will be sent even if the element is hidden.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question