1

Есть таблица с офисами (может быть 1 или 100 офисов). Для каждого офиса можно выбрать одну из трех опций, нажав на радио-кнопку. Что мне нужно, так это раздать имена кнопкам, чтобы у первого офиса радио-кнопки были с именем price-1, у второго price-2 и так далее.

<tr>
  <td>Office 1</td>
  <td><input type="radio" name="price-1"></td>
  <td><input type="radio" name="price-1"></td>
  <td><input type="radio" name="price-1"></td>
</tr>
<tr>
  <td>Office 2</td>
  <td><input type="radio" name="price-2"></td>
  <td><input type="radio" name="price-2"></td>
  <td><input type="radio" name="price-2"></td>
</tr>

...

<tr>
  <td>Office n</td>
  <td><input type="radio" name="price-n"></td>
  <td><input type="radio" name="price-n"></td>
  <td><input type="radio" name="price-n"></td>
</tr>

1 ответ 1

1
<?php $count = 100;

for ($i = 1; $i <= $count; ++$i): ?>

<tr>
  <td>Office <?= $i; ?></td>
  <td><input type="radio" name="price-<?= $i; ?>"></td>
  <td><input type="radio" name="price-<?= $i; ?>"></td>
  <td><input type="radio" name="price-<?= $i; ?>"></td>
</tr>

<?php endfor; ?>
3
  • напишите и про value уж тогда
    – splash58
    24 фев 2016 в 14:18
  • @splash58 value что? 24 фев 2016 в 14:46
  • 1
    вы не думаете, что след. вопрос будет: как понять, какая опция выбрана ? :)
    – splash58
    24 фев 2016 в 14:52

Ваш ответ

By clicking “Отправить ответ”, you agree to our terms of service and acknowledge you have read our privacy policy.

Всё ещё ищете ответ? Посмотрите другие вопросы с метками или задайте свой вопрос.