gpt4 book ai didi

javascript - 使用 jQuery Mobile 防止提交时重置表单

转载 作者:行者123 更新时间:2023-12-02 17:01:45 25 4
gpt4 key购买 nike

我试图在提交表单时完成它不会刷新和重置所有值的任务。我试图让它保留字段,这样我们就不必为相同顺序的多个条目重新输入所有信息。

我不确定你需要什么,这里是索引的大部分来源。

您可以通过http://vslan.net/pbs查看

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

最佳答案

您可以对表单使用 onsubmit return false。

    <form onsubmit="return false;" method='post' id="my_form">

直接在表单上尝试

关于javascript - 使用 jQuery Mobile 防止提交时重置表单,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25633744/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com