我在提交表单时试图完成它不刷新并重置所有值。我试图让它保留字段,因此我们不必为同一订单的多个条目重新输入信息。
我不确定你需要什么,这里是索引的大部分来源。
查看<html>
<head>
<title>Premium Beverage Supply</title>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="themes/premium_beverage_supply.css" />
<link rel="stylesheet" href="themes/jquery.mobile.icons.min.css" />
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.4.3/jquery.mobile.structure-1.4.3.min.css" />
<script src="http://code.jquery.com/jquery-1.11.1.min.js"></script>
<script src="http://code.jquery.com/mobile/1.4.3/jquery.mobile-1.4.3.min.js"> </script>
<script src="script/jqm.autoComplete-1.5.2-min.js"></script>
<script src="script/code.js"></script>
<link rel="shortcut icon" href="/favicon.ico" type="image/x-icon">
<link rel="icon" href="/favicon.ico" type="image/x-icon">
</head>
<body>
<? include("manage_posts.php"); ?>
<div data-role="page" class="" data-quicklinks="true" data-history="false" id="mainPage">
<div class="ui-header ui-bar-e" data-swatch="e" data-theme="e" data-form="ui-bar-e" data-role="header" role="banner" data-position="fixed">
<h1 style="text-align:left; margin-left:10px;">Premium Beverage Supply</h1>
<a href="#positionWindow" data-transition="slidedown" class="ui-btn ui-icon-gear ui-btn-icon-notext ui-corner-all ui-btn-right" data-rel="popup" data-position-to="window"> </a>
</div>
<div data-role="popup" id="positionWindow" data-theme="f" data-history="false">
<ul data-role="listview" data-inset="true" style="min-width:210px;">
<li data-role="list-divider">MENU OPTIONS</li>
<li data-icon="delete"><a href="pass.php">Clear Submissions</a></li>
<li data-icon="action"><a href="export.php" data-rel="external" data-ajax="false">Export to Excel</a></li>
</ul>
</div>
<div role="main" class="ui-content jqm-content" id="myHome">
<form method='post' id="my_form">
<div data-role="tabs" id="tabs" data-form="ui-body-f" data-theme="f" data-swatch="f">
<div data-role="navbar" data-form="ui-body-f" data-theme="f" data-swatch="f" class="ui-btn-f">
<ul>
<li><a href="#one" data-ajax="false" data-theme="f">Form</a></li>
<li><a href="display_posts.php?id=0" data-ajax="false" data-theme="f">Submissions</a> </li>
</ul>
</div>
<div id="one" class="ui-body-f ui-content ui-btn-f" data-theme="f" data-swatch="f">
//开始表格----------------------
<div class="ui-field-contain" class="ui-btn-f">
<select name="rep" id="rep" data-native-menu="false" data-form="ui-btn-up-f" data-theme="f" required>
<option value="">Representative</option>
<option value="Dale">Dale</option>
<option value="Dan">Dan</option>
<option value="Ron">Ron</option>
<option value="Scott">Scott</option>
</select>
</div>
<label for="slider-s">Number of Samples:</label>
<input name="sample" id="sample" value="0" min="0" max="6" data-highlight="true" type="range" class="ui-shadow-inset ui-body-f ui-corner-all ui-slider-input ui-bar-f " data-form="ui-body-f" data-theme="f" required>
<label for="textinput-2">Account Info:</label>
<input name="account" id="account" placeholder="Name" value="" type="text" class="input" data-form="ui-body-f" data-theme="f" required>
<input name="accountcity" id="accountcity" placeholder="City" value="" type="text" class="input" data-form="ui-body-f" data-theme="f" required data-required-msg="City is required.">
<input name="accountcontact" id="accountcontact" placeholder="Contact" value="" type="text" class="input" data-form="ui-body-f" data-theme="f">
<label for="textinput-2">Search Sample:</label>
<input type="text" id="items" name="items" placeholder="Item Sampled">
<ul id="suggestions" data-role="listview" data-inset="true"></ul>
<div data-role="collapsible" data-theme="f" data-swatch="f" class="ui-btn-f" data-form="ui-btn-f">
<h4>Other Expenses</h4>
<label for="text-basic">Supplier Name:</label>
<input name="suppliername" id="suppliername" value="" type="text" class="input" data-form="ui-body-f" data-theme="f">
<label for="text-basic">Expense:</label>
<input name="expense" id="expense" value="" type="text" class="input" data-form="ui-body-f" data-theme="f">
</div>
<br>
<a href="#popupDialog" data-rel="popup" data-position-to="window" data-role="button" data-inline="true" data-transition="pop" data-theme="e" data-swatch="e" class="ui-btn ui-btn-e ui-corner-all" data-form="ui-btn-up-e">Submit Request</a>
<div data-history="false" data-role="popup" id="popupDialog" data-overlay-theme="a" data-theme="e" data-dismissible="false" style="max-width:400px;" class="ui-corner-all">
<div data-role="header" data-theme="e" class="ui-corner-top">
<h1>Submission</h1>
</div>
<div data-role="content" data-theme="b" class="ui-corner-bottom ui-content" data-history="false">
<h3 class="ui-title">Are you sure you want to submit this form?</h3>
<a href="#" data-role="button" data-inline="true" data-rel="back" data-theme="e">Cancel</a>
<a href="javascript:{}" data-role="button" data-inline="true" data-rel="back" data-transition="flow" data-theme="e" onclick="document.getElementById('my_form').submit(); return false;" data-ajax="false">Submit</a>
</div>
</div>
</div>
</div>
</div>
</div>
</form>
</body>
</html>
答案 0 :(得分:2)
您可以对表单使用onsubmit return false。
<form onsubmit="return false;" method='post' id="my_form">
直接在表格上试试
答案 1 :(得分:0)
我会考虑将一个javascript框架(如Knockout.js或Angular.js)应用到您的View中。
Knockout有一些很好的教程,可以在这里找到: http://learn.knockoutjs.com/
基本上,它允许您轻松地将模型数据绑定到视图,这样当您执行回发时,您将保留视图中的值。
我建议在您的情况下使用Knockout,因为它可能更容易应用到您的页面开始。 Angular也很棒,但有更多的功能需要学习。否则,如果没有这些框架,您必须手动编写更多jQuery以将模型绑定到视图。框架使管理更容易。