Answer the question
In order to leave comments, you need to log in
How to change the form to javascript?
Hi everybody.
I have a popup, it has a select with the ability to replenish funds, 4 selection options,
and plus there is a form at the bottom. I got confused here, I decided to try to make a select on scss / js It turned out, but now I don’t understand how can I show the correct form of filling in the data when choosing a certain value?
structure in popup looks like this
<div class="select">
<div class="header">
<span class="current" id="currentSelect">вариант оплаты1</span>
</div>
<div class="select__body">
<div class="select__body-item">вариант оплаты1</div>
<div class="select__body-item">вариант оплаты2</div>
<div class="select__body-item">вариант оплаты3</div>
<div class="select__body-item">вариант оплаты4</div>
</div>
</div>
<form class="form1" action="#" id="pay1">
<input class="form1__tel-input" type="text" />
<input class="form__subbmit" type="submit" value="Вывести"/>
</form>
<form class="form2" action="#" id="pay2">
<input class="form2__tel-input" type="text" />
<input class="form__subbmit" type="submit" value="Вывести"/>
</form>
Answer the question
In order to leave comments, you need to log in
The simplest option : When loading the page, if the select has an empty value, hide all forms (display: none;/visibility:hidden;), if there are no empty values in the select, then the first option is selected in the select by default, the form corresponding to the option is visible , the rest are hidden. Each option in select has a value equal to the name of the form, when choosing an option, hide all forms, show the one selected by name.
I dashed off on my knee using jquery, you can write in vanilla, but I'm too lazy, I think the idea is already clear)
A more complicated option : When choosing an option, load the corresponding form with ajax into the prepared container.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question