O
O
oleshkin2016-09-01 15:17:52
HTML
oleshkin, 2016-09-01 15:17:52

How to make a table with changeable id parameters in Jade?

I'm trying to figure out how to create this block of html code in Jade:

<table>
<tr>
        <td>1.</td>
        <td>Перывй вопрос по 5-бальной шкале</td>
        <td>
          <div class="radios">
            <input type="radio" name="question1" id="q1a11" value="1"><label for="q1a11" class="radio">1</label></input>
            <input type="radio" name="question1" id="q1a12" value="2"><label for="q1a12" class="radio">2</label></input>
            <input type="radio" name="question1" id="q1a13" value="3"><label for="q1a13" class="radio">3</label></input>
            <input type="radio" name="question1" id="q1a14" value="4"><label for="q1a14" class="radio">4</label></input>
            <input type="radio" name="question1" id="q1a15" value="5"><label for="q1a15" class="radio">5</label></input>
          </div>
        </td>
      </tr>
      <tr>
        <td>2.</td>
        <td>Второй вопрос по 5-бальной шкале.</td>
        <td>
          <div class="radios">
            <input type="radio" name="question2" id="q2a11" value="1"><label for="q2a11" class="radio">1</label></input>
            <input type="radio" name="question2" id="q2a12" value="2"><label for="q2a12" class="radio">2</label></input>
            <input type="radio" name="question2" id="q2a13" value="3"><label for="q2a13" class="radio">3</label></input>
            <input type="radio" name="question2" id="q2a14" value="4"><label for="q2a14" class="radio">4</label></input>
            <input type="radio" name="question2" id="q2a15" value="5"><label for="q2a15" class="radio">5</label></input>
          </div>
        </td>
      </tr>
</table>

In Emmet, you can only shove 1 counter, so it is not entirely suitable in this case
(tr>td>{$.}^td>Сюда вопрос.^td>div.radios>(input:r[id=question$a$$ name=question$ value=$]label>label[for=q$a$$ class=radio]{$})*5)*28

on Jade, as I understand it, there should be 2 counters, one of which will make 24 rows in the table, and the other inside will print the radio button 5 times with the necessary identifiers and names. But nichrome does not work :). Where am I wrong?
- var q = 0
ul
  while q < 24
    tr
     td= q++
     td="Вопрос" 
     td
       div.radios
         - for (var x = 10; x < 15; x++)
         input(type=radio, value='#{q}', id='q#{q}a#{x}')
           label(for='q#{q}a#{x}, class='radio')#{x}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry Gusev, 2016-09-01
@illi

- var q = 0
ul
  while q < 24
    tr
     td= q++
     td="Вопрос" 
     td
       div.radios
         - for (var x = 10; x < 15; x++) {
           input(type=radio, value='#{q}', id='q#{q}a#{x}')
             label(for='q#{q}a#{x}, class='radio')#{x}
        - }

try this with brackets

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question