使用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) 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>