使用2个选项卡创建表单(FORM和Preview)

时间:2015-01-21 15:55:43

标签: javascript php jquery html css

所以这就是我需要创造的东西 http://i.gyazo.com/cadc9c6726d2ba16f8072f0bae73c966.png 这就是我现在所做的 我仍然需要做的功能,我不知道如何:

1)在“预览”选项卡中,ADD CAMPAING选项卡中填写的所有信息必须显示在标签标签中,但我知道如何在单击按钮提交之前保存并显示它们...(这些是最多的我不知道如何解决的严重问题

2)我需要把标题放在"创建新的CAMPAIGN"当ADD Campaigning选项卡打开时,当我单击/切换到REVIEW时,它必须是REVIEW DETAILS

3)点击提交/添加广告系列时,必须使用javascript进行输入检查..不知道如何操作

感谢所有能够帮助的人......



 $(document).ready(function(){ 
  $("#linkOne").click(function(e){
      e.preventDefault();
      $("#preview").removeClass("active");
      $("#add").addClass("active");
  });
  $("#linkTwo").click(function(e){
      e.preventDefault();
      $("#add").removeClass("active");
      $("#preview").addClass("active");
  });
});
 

.tab-pane{
  display: none;
}

.active
{
  display: block !important;
}

 

<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>jQuery UI Tabs - Collapse content</title>
  <link rel="stylesheet" type="text/css" href="style.css">
 <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.0/css/bootstrap.min.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.0/css/bootstrap-theme.min.css">
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.0/js/bootstrap.min.js"></script>
 </head>
<body>
 
<div class="bs-example">
<ul class="nav nav-tabs" id="myTab">
    <li><a id="linkOne" href="#add">ADD CAMPAIGN</a></li>
    <li><a id="linkTwo" href="#preview">PREVIEW</a></li>

</ul>
<div class="tab-content">
    <div id="add" class="tab-pane active">

      <form method="post"  action="javascript.php">
                  <table>
                <tr>
                <th> 
                  <label for="campaignname">Campaign name</label>
                </th>
                <td>
                  <input type = "text" name="campaignname" id="campaignname" >
                </td>
              
              </tr>
              <tr>
                <th> 
                  <label for="dailybudget">Daily budget</label>
                </th>
                <td>
                  <input type = "text" name="dailybudget" id="dailybudget" placeholder="Min $10/day">
                </td>
              
              </tr>

              <tr>
                <th> 
                   <label for="campaigntype">Campaign type</label>
                </th>
                <td>                
                  <select name="campaigntype" id="campaigntype" >
               
                  <option value="" disabled selected>Dialog click to message</option>
                  <option value="a"> a </option>
                  <option value="b"> b </option>
                  <option value="c"> c </option>
                  <option value="d"> d </option>
                  </select>
                </td>
              
              </tr>

              <tr>
                <th> 
                  <label for="startdate">Start Date</label>
                </th>
                <td>
                  <input type = "text" name="startdate" id="startdate" placeholder="YYYY-MM-DD H:I">
                </td>
              
              </tr>

              <tr>
                <th> 
                  <label for="enddate">End Date</label>
                </th>
                <td>
                  <input type = "text" name="enddate" id="enddate" placeholder="YYYY-MM-DD H:I" >
                </td>
              
              </tr>

                 <tr>
                <th> 
                   <label for="catagory">Catagory</label>
                </th>
                <td>                
                  <select name="catagory" id="catagory">
                  <option value="" disabled selected>Select catagory...</option>
                  <option value="a"> a </option>
                  <option value="b"> b </option>
                  <option value="c"> c </option>
                  <option value="d"> d </option>
                  </select>
                </td>
              
              </tr>

 <tr>
                <th> 
                   <label for="platformtype">Platform type</label>
                </th>
                <td>                
                  <select name="platformtype" id="platformtype">
                  <option value="" disabled selected>Select platform...</option>
                  <option value="a"> a </option>
                  <option value="b"> b </option>
                  <option value="c"> c </option>
                  <option value="d"> d </option>
                  </select>
                </td>
              
              </tr>

            </table>
            <input type="submit" value="Send">
      </form>     
      
      
    </div>
    <div id="preview" class="tab-pane">
        


        <form method="post"  action="javascript.php">
                          <table>
                        <tr>
                        <th> 
                          <label for="campaignname">Campaign name</label>
                        </th>
                       
                      
                      </tr>
                      <tr>
                        <th> 
                          <label for="dailybudget">Daily budget</label>
                        </th>
                       
                      
                      </tr>

                      <tr>
                        <th> 
                           <label for="campaigntype">Campaign type</label>
                        </th>
                        
                      
                      </tr>

                      <tr>
                        <th> 
                          <label for="startdate">Start Date</label>
                        </th>
                      
                      
                      </tr>

                      <tr>
                        <th> 
                          <label for="enddate">End Date</label>
                        </th>
                      
                      
                      </tr>

                         <tr>
                        <th> 
                           <label for="catagory">Catagory</label>
                        </th>
                      
                      
                      </tr>

         <tr>
                        <th> 
                           <label for="platformtype">Platform type</label>
                        </th>
                      
                      
                      </tr>

                    </table>
                    <input type="submit" value="Send">
              </form>     

    </div>

    </div>
</div>



</body>
</html>
&#13;
&#13;
&#13;

1 个答案:

答案 0 :(得分:0)

1)这是您第一个问题的解决方案。我添加了一个函数:updateFields(),单击预览选项卡时会调用该函数,该函数会填充各种预览输入框。

你应该能够根据这个来弄清楚其余部分。

$(document).ready(function() {
  $("#linkOne").click(function(e) {
    e.preventDefault();
    $("#preview").removeClass("active");
    $("#add").addClass("active");
  });
  $("#linkTwo").click(function(e) {
    e.preventDefault();
    $("#add").removeClass("active");
    $("#preview").addClass("active");
  });
});

function updateFields() {
  $("#campaignNameLabel").text(" : " + $("#campaignname").val());
  $("#dailyBudgetLabel").text(" : " + $("#dailybudget").val());
  $("#campaignTypeLabel").text(" : " + $("#campaigntype").val());
  $("#startDateLabel").text(" : " + $("#startdate").val());
  $("#endDateLabel").text(" : " + $("#enddate").val());
  $("#categoryLabel").text(" : " + $("#catagory").val());
  $("#platformTypeLabel").text(" : " + $("#platformtype").val());
}
.tab-pane {
  display: none;
}
.active {
  display: block !important;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<!doctype html>
<html lang="en">

<head>
  <meta charset="utf-8">
  <title>jQuery UI Tabs - Collapse content</title>
  <link rel="stylesheet" type="text/css" href="style.css">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.0/css/bootstrap.min.css">
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.0/css/bootstrap-theme.min.css">
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.0/js/bootstrap.min.js"></script>
</head>

<body>

  <div class="bs-example">
    <ul class="nav nav-tabs" id="myTab">
      <li><a id="linkOne" href="#add">ADD CAMPAIGN</a>
      </li>
      <li><a id="linkTwo" href="#preview" onclick="updateFields()">PREVIEW</a>
      </li>

    </ul>
    <div class="tab-content">
      <div id="add" class="tab-pane active">

        <form method="post" action="javascript.php">
          <table>
            <tr>
              <th>
                <label for="campaignname">Campaign name</label>
              </th>
              <td>
                <input type="text" name="campaignname" id="campaignname">
              </td>

            </tr>
            <tr>
              <th>
                <label for="dailybudget">Daily budget</label>
              </th>
              <td>
                <input type="text" name="dailybudget" id="dailybudget" placeholder="Min $10/day">
              </td>

            </tr>

            <tr>
              <th>
                <label for="campaigntype">Campaign type</label>
              </th>
              <td>
                <select name="campaigntype" id="campaigntype">

                  <option value="" disabled selected>Dialog click to message</option>
                  <option value="a">a</option>
                  <option value="b">b</option>
                  <option value="c">c</option>
                  <option value="d">d</option>
                </select>
              </td>

            </tr>

            <tr>
              <th>
                <label for="startdate">Start Date</label>
              </th>
              <td>
                <input type="text" name="startdate" id="startdate" placeholder="YYYY-MM-DD H:I">
              </td>

            </tr>

            <tr>
              <th>
                <label for="enddate">End Date</label>
              </th>
              <td>
                <input type="text" name="enddate" id="enddate" placeholder="YYYY-MM-DD H:I">
              </td>

            </tr>

            <tr>
              <th>
                <label for="catagory">Catagory</label>
              </th>
              <td>
                <select name="catagory" id="catagory">
                  <option value="" disabled selected>Select catagory...</option>
                  <option value="a">a</option>
                  <option value="b">b</option>
                  <option value="c">c</option>
                  <option value="d">d</option>
                </select>
              </td>

            </tr>

            <tr>
              <th>
                <label for="platformtype">Platform type</label>
              </th>
              <td>
                <select name="platformtype" id="platformtype">
                  <option value="" disabled selected>Select platform...</option>
                  <option value="a">a</option>
                  <option value="b">b</option>
                  <option value="c">c</option>
                  <option value="d">d</option>
                </select>
              </td>

            </tr>

          </table>
          <input type="submit" value="Send">
        </form>


      </div>
      <div id="preview" class="tab-pane">



        <form method="post" action="javascript.php">
          <table>
            <tr>
              <th>
                <label for="campaignname">Campaign name</label>
              </th>
              <td>
                <label id="campaignNameLabel"></label>
              </td>

            </tr>
            <tr>
              <th>
                <label for="dailybudget">Daily budget</label>
              </th>
              <td>
                <label id="dailyBudgetLabel"></label>
              </td>


            </tr>

            <tr>
              <th>
                <label for="campaigntype">Campaign type</label>
              </th>
              <td>
                <label id="campaignTypeLabel"></label>
              </td>

            </tr>

            <tr>
              <th>
                <label for="startdate">Start Date</label>
              </th>
              <td>
                <label id="startDateLabel"></label>
              </td>


            </tr>

            <tr>
              <th>
                <label for="enddate">End Date</label>
              </th>
              <td>
                <label id="endDateLabel"></label>
              </td>


            </tr>

            <tr>
              <th>
                <label for="catagory">Category</label>
              </th>
              <td>
                <label id="categoryLabel"></label>
              </td>


            </tr>

            <tr>
              <th>
                <label for="platformtype">Platform type</label>
              </th>
              <td>
                <label id="platformTypeLabel"></label>
              </td>


            </tr>

          </table>
          <input type="submit" value="Send">
        </form>

      </div>

    </div>
  </div>



</body>

</html>