There is a div array, with an indefinite number of blocks. It is necessary for everyone to add +1 to id. Tell me how to do what id = demo would add a number to the title? demo1, demo2 .....

<div class="filter_characteristic"> <a href="#demo" data-toggle="collapse">1</a> <div id="demo" class="collapse"> <a href="#demo" data-toggle="collapse">2</a> <div id="demo" class="collapse"> <a href="#demo" data-toggle="collapse">3</a> <div id="demo" class="collapse"> </div> 

The PHP code looks like this:

  <div class="filter_characteristic"> <?php foreach($characteristic_displayfields as $ch_id){?> <?php if (is_array($characteristic_fieldvalues[$ch_id])){?> <a href="#demo" data-toggle="collapse"><?php print $characteristic_fields[$ch_id]->name;?></a> <div id="demo" class="collapse"> <input type="hidden" name="extra_fields[<?php print $ch_id?>][]" value="0" /> <?php foreach($characteristic_fieldvalues[$ch_id] as $val_id=>$val_name){?> <label><span class="button_checkbox"><input type="checkbox" hidden name="extra_fields[<?php print $ch_id?>][]" value="<?php print $val_id;?>" <?php if (is_array($extra_fields_active[$ch_id]) && in_array($val_id, $extra_fields_active[$ch_id])) print "checked";?> onclick="document.jshop_filters.submit();" /> <span><?php print $val_name;?></span></span></label> <?php }?> <br/></div> <?php }?> <?php }?> </div></div> 
  • You have a html curve. - Visman
  • This is a torn piece from the template. Php code can not attach to the comment. - Victor
  • Possible duplicate question: Number id - Qwertiy
  • Although, probably in vain I close, the php tag is more correct to add and give a solution in php ... - Qwertiy
  • I understand that at the beginning of the code, I need to specify a script that will change the id, but all the options I have tried do not work, because my hands are crooked. I tried the scripts from your link. - Victor

1 answer 1

Not?

  <div class="filter_characteristic"> <?php foreach($characteristic_displayfields as $ch_id){?> <?php if (is_array($characteristic_fieldvalues[$ch_id])){?> <a href="#demo" data-toggle="collapse"><?php print $characteristic_fields[$ch_id]->name;?></a> <div id="demo<? echo $ch_id ?>" class="collapse"> <input type="hidden" name="extra_fields[<?php print $ch_id?>][]" value="0" /> <?php foreach($characteristic_fieldvalues[$ch_id] as $val_id=>$val_name){?> <label><span class="button_checkbox"><input type="checkbox" hidden name="extra_fields[<?php print $ch_id?>][]" value="<?php print $val_id;?>" <?php if (is_array($extra_fields_active[$ch_id]) && in_array($val_id, $extra_fields_active[$ch_id])) print "checked";?> onclick="document.jshop_filters.submit();" /> <span><?php print $val_name;?></span></span></label> <?php }?> <br/></div> <?php }?> <?php }?> </div></div> 
  • Please try to write more detailed answers. I am sure the author of the question would be grateful for your expert commentary on the code above. - Nicolas Chabanovsky