I
I
Ilya Balabuev2017-10-21 13:32:03
JavaScript
Ilya Balabuev, 2017-10-21 13:32:03

How to write code to be more efficient?

I'm developing some kind of system :)
There was a problem when generating data. It is necessary to place the data in an object, more precisely in an associative array contained in the object. This can be done using `.serializeArray()` and passed to an object where there is a provided **set...** method, which I have shown in the code example below. But it seems to me that this method is not very good and correct, and I want it to be done professionally. I have little experience in programming, so I want to do it the right way.

Code for the first screen:

<div id="tab1" >
            <div class="row"> 
              <div class="col-xs-10"><h3>Описание</h3></div>
              <div class="col-xs-2"><button type="button" id="step1" class="next btn btn-success pull-right">Далее</button></div>
            </div>
            <form id="descrip">
            <div class="form-group">
              <label for="titleT">Название теста:</label>
              <input type="text" class="form-control" name="titleT" placeholder="Название теста" />
            </div>
            <div class="form-group">
              <label for="descripT">Описание теста:</label>
              <textarea class="form-control" name="descripT" placeholder="Описание теста"></textarea>
            </div>
            <div class="form-group">
              <label for="tarAidience">Выберите целивую аудиторию:</label>
              <select name="tarAidience" class="form-control">
                <option value="teach">Преподаватели</option>
                <option value="stud">Студенты/абитуриенты</option>
                <option value="all">Для всех</option>
              </select>
            </div>
            <div class="form-group">
              <label class="checkbox-inline"><input type="checkbox" name="answer">Проверять ответы</label>
            </div>
            </form>
          </div>


Code for the second <screen:
<div class="">
              <form id="Questions">
              <div class="form-group">
                <label for="question">Вопрос:</label>
                <input type="text" name="" id="question" class="form-control" placeholder="Введите вопрос" />
              </div>
              <div class="row">
                <div class="form-group col-xs-10">
                  <label>Выбирете тип вопроса:</label>
                  // Тут типы вопросов. Убрал т.к. и так много текста
                </div>
                <div class="col-xs-2">
                  <div class="pull-right btn btn-success" id="addBtn"><span class="addimg"></span></div>
                </div>
              </div>
            </form>
            </div>

59eb218a9d5f9048253399.png
59eb21a65286f067186423.png

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question