Как создать модальную всплывающую форму - PullRequest
0 голосов
/ 17 апреля 2019

введите описание изображения здесь

Я пытаюсь создать всплывающее окно с помощью кнопки добавления, чтобы форма могла отображаться в модальном всплывающем окне прямо сейчас, форма отображается уже, но яхочу, чтобы он отображался после того, как я нажму кнопку добавления, есть ли способ исправить это

    <html>
    <head>
      <meta charset="utf-8">
      <meta name="viewport" content="width=device-width">
    <link href="mystyle.css" rel="stylesheet">
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
    <link href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" rel="stylesheet"/>
    <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"></script>
    <script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.2/jquery-ui.min.js"></script>
      <link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.2/themes/smoothness/jquery-ui.css" />
    <script src="mycrud.js"></script>
    </head>
    <body>
      <title>My Movies</title>
      <header>
        <h1>Movies</h1>
      </header>
    <button id = "showMovies" type="button" class="btn btn-primary"  data-toggle="modal"
    data-target=#exampleModal>All Movies</button>
    <div class="modal fade" id="exampleModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
        <div class="modal-dialog" role="document">
          <div class="modal-content">
            <div class="modal-header">
              <h5 class="modal-title" id="exampleModalLabel">Modal title</h5>
              <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                <span aria-hidden="true">&times;</span>
              </button>
            </div>
          </div>
        </div>
      </div>
    <div class = "modal-body">
    <form id="newForm">
        <div class="form-group row">
          <label for="idmovielist" class="col-sm-2 col-form-label">idmovielist</label>
            <div class="col-sm-10">
              <input type="text" class="form-control" id="intNum" placeholder="idmovielist">
            </div>
        </div>
        <div class="form-group row">
          <label for="name" class="col-sm-2 col-form-label">name</label>
            <div class="col-sm-10">
              <input type="text" class="form-control" id="name" placeholder="name">
            </div>
        </div>
        <div class="form-group row">
          <label for="thumnail_path" class="col-sm-2 col-form-label">thumnail_path</label>
            <div class="col-sm-10">
              <input type="text" class="form-control" id="thumnail_path" placeholder="thumnail_path">
            </div>
        </div>
        <div class="form-group row">
          <label for="description" class="col-sm-2 col-form-label">description</label>
            <div class="col-sm-10">
              <input type="text" class="form-control" id="description" placeholder="description">
            </div>
        </div>
        <div class="form-group row">
          <label for="year_released" class="col-sm-2 col-form-label">year_released</label>
            <div class="col-sm-10">
              <input type="text" class="form-control" id="year_released" placeholder="year_released">
            </div>
        </div>
        <div class="form-group row">
          <label for="language_released" class="col-sm-2 col-form-label">language_released</label>
            <div class="col-sm-10">
              <input type="text" class="form-control" id="language_released" placeholder="language_released">
            </div>
        </div>
      </form>
    </div>
    <button id = "movieAdded" type="button" class="btn btn-primary" data-toggle="modal"
    data-target=#exampleModal>Add</button>
    <table class="table table-bordered table-hover" width="100%">
      <thead style="background-color:#ddd;" class="table-borderless">
        <tr>
          <th>idmovielist</th>
          <th>name</th>
          <th>thumnail_path</th>
          <th>description</th>
          <th>year_released</th>
          <th>language_released</th>
          <th>Action</th>
        </tr>
      </thead>
      <tbody id="movies">
      </tbody>
    </table>
    </body>
    </html>

Это мой HTML-код. У меня есть код формы и модальный код из начальной загрузки, где я могу разместить модальный код, чтобы эта форма была всплывающей.В основном я создаю всплывающую форму, и если мне нужно добавить что-нибудь еще, чтобы помочь вам, ребята, ответить на вопрос, пожалуйста, дайте мне знать

1 Ответ

0 голосов
/ 17 апреля 2019

Ваш modal-body класс находится за пределами модальной.Чтобы решить эту проблему, поместите ваш <div class="modal-body"></div> в модальный.

Я изменил ваш код.пожалуйста, смотрите ..

<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
<link href="mystyle.css" rel="stylesheet">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.2/jquery-ui.min.js"></script>
  <link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.2/themes/smoothness/jquery-ui.css" />
<script src="mycrud.js"></script>
</head>
<body>
  <title>My Movies</title>
  <header>
    <h1>Movies</h1>
  </header>
<button id = "showMovies" type="button" class="btn btn-primary"  data-toggle="modal"
data-target=#exampleModal>All Movies</button>
<div class="modal fade" id="exampleModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
    <div class="modal-dialog" role="document">
      <div class="modal-content">
        <div class="modal-header">
          <h5 class="modal-title" id="exampleModalLabel">Modal title</h5>
          <button type="button" class="close" data-dismiss="modal" aria-label="Close">
            <span aria-hidden="true">&times;</span>
          </button>
        </div>

        <div class = "modal-body">
<form id="newForm">
    <div class="form-group row">
      <label for="idmovielist" class="col-sm-2 col-form-label">idmovielist</label>
        <div class="col-sm-10">
          <input type="text" class="form-control" id="intNum" placeholder="idmovielist">
        </div>
    </div>
    <div class="form-group row">
      <label for="name" class="col-sm-2 col-form-label">name</label>
        <div class="col-sm-10">
          <input type="text" class="form-control" id="name" placeholder="name">
        </div>
    </div>
    <div class="form-group row">
      <label for="thumnail_path" class="col-sm-2 col-form-label">thumnail_path</label>
        <div class="col-sm-10">
          <input type="text" class="form-control" id="thumnail_path" placeholder="thumnail_path">
        </div>
    </div>
    <div class="form-group row">
      <label for="description" class="col-sm-2 col-form-label">description</label>
        <div class="col-sm-10">
          <input type="text" class="form-control" id="description" placeholder="description">
        </div>
    </div>
    <div class="form-group row">
      <label for="year_released" class="col-sm-2 col-form-label">year_released</label>
        <div class="col-sm-10">
          <input type="text" class="form-control" id="year_released" placeholder="year_released">
        </div>
    </div>
    <div class="form-group row">
      <label for="language_released" class="col-sm-2 col-form-label">language_released</label>
        <div class="col-sm-10">
          <input type="text" class="form-control" id="language_released" placeholder="language_released">
        </div>
    </div>
  </form>
</div>
      </div>
    </div>
  </div>

<button id = "movieAdded" type="button" class="btn btn-primary" data-toggle="modal"
data-target=#exampleModal>Add</button>
<table class="table table-bordered table-hover" width="100%">
  <thead style="background-color:#ddd;" class="table-borderless">
    <tr>
      <th>idmovielist</th>
      <th>name</th>
      <th>thumnail_path</th>
      <th>description</th>
      <th>year_released</th>
      <th>language_released</th>
      <th>Action</th>
    </tr>
  </thead>
  <tbody id="movies">
  </tbody>
</table>
</body>
</html>
...