doushi3189 2015-01-21 15:55
浏览 81
已采纳

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

So this is what i need to create http://i.gyazo.com/cadc9c6726d2ba16f8072f0bae73c966.png and this what i made till now the features that i still need to do and i don't know how is:

1)In the Preview tab all the information that was filled in in ADD CAMPAING tab must be shown in a label tags but i do know how save and show them before the button submit is clicked ... (These are the most serious problem that i don't know how to solve )

2)I need to put Headline of "Create New CAMPAIGN" when the ADD Campaing Tab is on and when i click/switch to REVIEW it must be REVIEW DETAILS

3) When Submit/Add campaign clicked there must be input check with javascript.. no clue how to do it

Thanks for all who can HElp...

 $(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>

</div>
  • 写回答

1条回答 默认 最新

  • dow56114 2015-01-21 18:35
    关注

    1) Here is the solution to your first question. I added a function: updateFields(), that gets called when the preview tab is clicked, and that function populates your various preview input boxes.

    You should be able to figure out the rest based on this.

    $(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>

    </div>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥17 pro*C预编译“闪回查询”报错SCN不能识别
  • ¥15 微信会员卡接入微信支付商户号收款
  • ¥15 如何获取烟草零售终端数据
  • ¥15 数学建模招标中位数问题
  • ¥15 phython路径名过长报错 不知道什么问题
  • ¥15 深度学习中模型转换该怎么实现
  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向