所以这就是我需要创建的 http://i.gyazo.com/cadc9c6726d2ba16f8072f0bae73c966.png 这是我到目前为止所做的 我仍然需要做但我不知道如何做的功能是:
1) 在预览选项卡中,所有在添加广告系列选项卡中填写的信息都必须显示在标签标签中,但我知道如何在单击提交按钮之前保存和显示它们......(这些是最我不知道如何解决的严重问题)
2) 当打开 ADD Campaing 选项卡时,我需要放置“Create New CAMPAIGN”标题,当我单击/切换到 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>
最佳答案
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>
关于javascript - 创建具有 2 个选项卡的表单(表单和预览),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28071476/