serjarfan
@serjarfan
начинающий веб-разработчик

Как на основе input-ов перебрать все варианты и вывести определенный блок, который сначала скрыт?

Здраствуйте, мне необходимо на основе инпутов, принимая по одному из каждой линии перебрать все варианты и для каждого вывести свой блок, который сначала должен быть скрыт. Я плохо знаю js, подскажите пожалуйста, что нужно поправить или дописать чтоб работала проверка. Спасибо.
<!--first line-->
		<input type="button" value="1" id="a1" name="buttona" onclick="changebtn(this.value);"/>
		<input type="button" value="2" id="a2" name="buttona" onclick="changebtn(this.value);"/>
		<input type="button" value="3" id="a3" name="buttona" onclick="changebtn(this.value);"/>
		<!-- second line-->
		<input type="button" value="4" id="b1" name="buttonb" onclick="changebtn(this.value);"/>
		<input type="button" value="5" id="b2" name="buttonb" onclick="changebtn(this.value);"/>
		<!--third line-->
		<input type="button" value="6" id="c1" name="buttonc" onclick="changebtn(this.value);"/>
		<input type="button" value="7" id="c2" name="buttonc" onclick="changebtn(this.value);"/>
		<input type="button" value="8" id="c3" name="buttonc" onclick="changebtn(this.value);"/>

<!-- my pay buttons-->
<div style="display: none;" id="button1" class="custom_pay_button1">1</div>
<div style="display: none;" id="button2" class="custom_pay_button2">2</div>
<div style="display: none;" id="button3" class="custom_pay_button3">3</div>
<div style="display: none;" id="button4" class="custom_pay_button4">4</div>
<div style="display: none;" id="button5" class="custom_pay_button5">5</div>
<div style="display: none;" id="button6" class="custom_pay_button6">6</div>
<div style="display: none;" id="button7" class="custom_pay_button7">7</div>
<div style="display: none;" id="button8" class="custom_pay_button8">8</div>

var button1 = document.getElementById("button1");
 var button2 = document.getElementById("button2");
 var button3 = document.getElementById("button3");
 var button4 = document.getElementById("button4");
 var button5 = document.getElementById("button5");
 var button6 = document.getElementById("button6");
 var button7 = document.getElementById("button7");
 var button8 = document.getElementById("button8");
 var a;
 var b;
 var c;
 
 function changebtn(value){
  if(value==1){
  a=1;
 }
  if(value==2){
  a=2;
 } 
 if(value==3){
  a=3;
 }
 if(value==4){
  b=1;
 }
 if(value==5){
  b=2;
 }
 if(value==6){
  c=1;
 } 
 if(value==7){
  c=2;
 }
 if(value==8){
  c=3;
 }
 
if (a=1 && b=1 && c=1) {
  button1.style.display="block";
}
 
}
  • Вопрос задан
  • 165 просмотров
Пригласить эксперта
Ответы на вопрос 1
@matetyson
Ответ написан
Комментировать
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы