我已经测试了滚动到DIV ID 的所有方法,但不起作用我知道出了问题,但我不知道是什么,这是我的 jquery 脚本
$("#sub").click( function() {
$("#myForm").validate({
rules: {
page: {
required: true,
url: true
},
link: {
required: true,
url: true
}
},
submitHandler: function(form) {
$.post( $("#myForm").attr("action"), $("#myForm :input").serializeArray(),
function(info){
$("#result").html(info);
});
clearInput();
$("#myForm").submit( function() {
return false;
});
}
});
});
function clearInput() {
$('html, body').animate({
scrollTop: $("#result").offset().top
}, 2000);
}
Run Code Online (Sandbox Code Playgroud)
我不知道是否有什么东西混合了东西,但 jquery 不滚动,我scrolltop()在一个新的 php 文件中测试该函数并且工作正常,但当我在这个文件上使用它时却没有。
更新:
感谢您的帮助 netblognet 我已经得到它,我做了这个:
$("#sub").click( function() {
$("#myForm").validate({
rules: {
page: {
required: true,
url: true …Run Code Online (Sandbox Code Playgroud) 在顶部,我有一个会话启动,会话 ID 可以在所有网页上传递,因为所有网页上的 ID 都是相同的,这还包括一个名为“用户名”的会话变量,其值为 Guest。我想将此变量更改为表单中输入的变量。这是我的第一篇文章,很抱歉有任何错误。
<form class="form1" method="post" action="./" id="form1">
<fieldset>
<ul>
<p>Please enter your username to continue to the webshop.</p>
<label for="name">User Name:</label><span><input type="text" name="username" placeholder="User Name" class="required" role="input" aria-required="true"/></span>
<input class="submit .transparentButton" value="Next" type="submit" name="Submit"/>
</ul>
<br/>
</fieldset>
</form>
<?
if (isset($_POST['Submit'])) {
$_SESSION['username'] = $_POST['username'];
}
?>
Run Code Online (Sandbox Code Playgroud)
谢谢
所以我有一个输入表单,用户将在其中输入用户名,提交后,站点将根据用户名收集信息,但是,如果用户名中有空格,则用户名将变为无效(不存在)。我将如何在 PHP 中添加消除任何和所有空格的行为,以便最终提交的用户名不是john doe,而是johndoe.
这是我的表单代码:
<form action="php.php" method="GET">
<div class="form-group">
<label for="username">Username:</label>
<input type="text" class="form-control" id="username" name="username" placeholder="Enter username" required>
</div>
<button type="submit" class="btn btn-default">Submit</button>
</form>
Run Code Online (Sandbox Code Playgroud)
这是php.php文件代码:
//I GUESS THIS IS WHERE THE TRIMMING SHOULD HAPPEN?
<?php
//error_reporting(E_ALL & ~E_NOTICE);
// Load the username from somewhere
if (
$username = $_GET["username"]
) {
//do nothing
} else {
//$username = "notch";
echo "Oops! Something went wrong!";
}
?>
Run Code Online (Sandbox Code Playgroud) 我试图在表单上放置一个内联onsubmit脚本,但它不起作用:
<!DOCTYPE html>
<html>
<head></head>
<body>
<form onsubmit="(function(event){console.log(event); return false;})(this);">
<button type="submit">Submit</button>
</form>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
并且函数的参数是事件还是表单元素?
我正在学习VBA。
我想默默地填写网络表格,例如
Set IE = CreateObject("internet explorer.Application")
IE.VIsible = False
Run Code Online (Sandbox Code Playgroud)
当我用它加载网址时,它说我应该使用另一个浏览器打开它。
我想让它在任何操作系统上兼容。我找到了这个
ActiveWorkbook.FollowLinkAddress "myurl.com"
Run Code Online (Sandbox Code Playgroud)
但我不知道如何将其设置为变量,例如
Set IE = ActiveWorkbook.FollowLinkAddress "myurl.com"
IE.Visible = false
Run Code Online (Sandbox Code Playgroud)
然后我可以做一些事情,比如填写输入字段,单击按钮,......
Set btn = IE.getElementById(...........
btn.Click = true
Run Code Online (Sandbox Code Playgroud)
这是让我头疼的网址:
https://sellercentral.amazon.com/hz/fba/profitabilitycalculator/index?lang=en_US
什么是代码,如果我有复选框,并选择它(没有任何提交按钮)显示我提交按钮
<html>
<head>
<title>test</title>
<form method="post">
<?php
//what will be the code here?
?>
<input type='checkbox' name='cb'>
</form>
</html>
Run Code Online (Sandbox Code Playgroud) 首次运行Page_B时(通过单击另一页面上的提交按钮,Page_A),可以很好地打印变量SG(从Page_A发送)的值.但是,当我单击Page_B上的提交按钮(如果我错了,请更正我,再次运行Page_B),打印空间变空.我的结论是,作为提交操作的结果,SG的内容(值)已被删除.这不是我想要的,因为这个值需要进一步在Page_B(代码尚未编写).如何避免这种删除发生?
这是Page_B的代码:
<html>
<?php
$SG=$_POST['SG'];
print ($SG);
?>
<form action="Page_B.php" method="POST">
<input type="text" name="trekking">
<input type="submit">
</form>
<?php
$T=$_POST['trekking'];
print ($T);
?>
</html>
Run Code Online (Sandbox Code Playgroud) 我想要一个带有4个提交按钮的表单。一旦按下它们中的任何一个,它们就会对具有不同内容的同一页面进行外壳调用。为了确定内容是什么,我将编写一个PHP脚本,但到目前为止还没有结束。我的问题是,我需要传递值。
我在这里找到了问题的答案(一种形式有两个提交按钮)。我复制并调整了代码,但无法正常工作。当我想使用定义的名称访问$ _POST数组时,它说这是一个未知索引。到目前为止,这是我的相关代码。
<div>
<form action="nutzerverwaltung.php" method="post">
<input type="submit" class="nv_select" name="nv_select" value="Nutzer hinzufuegen" />
<input type="submit" class="nv_select" name="nv_select" value="Nutzer loeschen" />
<input type="submit" class="nv_select" name="nv_select" value="Nutzer bearbeiten" />
<input type="submit" class="nv_select" name="nv_select" value="Alle Nutzer anzeigen" />
</form>
<br />
</div>
<?php if ($_POST["nv_select"] == "Nutzer hinzufuegen") echo "Hallo"; ?>
Run Code Online (Sandbox Code Playgroud)
我究竟做错了什么??
约翰
我想要的是拥有一个JavaScript函数,它发送一个POST任意站点,并在网站上保持"它被执行"的全部时间.它不一定要用表格来完成!
如果可能的话,我不想使用jQuery.
我怎样才能做到这一点?
我如何单击给定HTML上的Submit按钮
<span class="sbt-btn-wrap relative">
<input class="submit icon" type="submit" onclick="submitmnLogin($(this), 'testPrepLogin');trackGaEvent('Content Hub Home','Login Popup','Login Button');">
Run Code Online (Sandbox Code Playgroud)
我试过了
driver.findElement(By.className("sbt-btn-wrap relative")).click();
Run Code Online (Sandbox Code Playgroud)
和
driver.findElement(By.className("submit icon")).click();
Run Code Online (Sandbox Code Playgroud)
但它不起作用。
第一:始终是同一个动作.二:表单有多个"CSS SUBMITS"之类
<form action="/myaction" method="POST">
<a id="foo1" name="foo1" href="#" role="form_button">submit1!</a>
<a id="foo2" name="foo2" href="#" role="form_button">submit2!</a>
<a id="foo3" name="foo3" href="#" role="form_button">submit3!</a>
<input type="submit" id="canfoo" name="canfoo" value="I can process this"/>
</form>
<script>
$('a[role=form_button], div[role=form_button], span[role=form_button]').bind( 'click', function(){ $('form').submit(); } );
</script>
Run Code Online (Sandbox Code Playgroud)
我怎么能在/ myaction中这样做:
if ($_POST['foo1']) { action; return; } // :(
if ($_POST['foo2']) { action; return; } // :(
if ($_POST['foo3']) { action; return; } // :(
if ($_POST['canfoo']) { action; return; } // THIS WORKKKKKSS!!
Run Code Online (Sandbox Code Playgroud)
我怎样才能使foo1,foo2,foo3工作?
(我使用jQuery:
$('a[role=form_button], div[role=form_button], span[role=form_button]').bind( 'click', …Run Code Online (Sandbox Code Playgroud) 我有动态数量的字段的html表单,例如:
<form id="myform">
<input type="text" id="input1">
<input type="text" id="input2">
<input type="text" id="input3">
...
<input type="text" id="inputN">
<span id="button_click"> CLICK </span>
</form>
Run Code Online (Sandbox Code Playgroud)
和jQuery是:
$("#button_click").click(function(){
$.post("myfile.php",
{
XXXX:YYYY
},
function(data,status){
// do anyting
});
});
Run Code Online (Sandbox Code Playgroud)
我不知道确切的字段数,所以我无法填写XXXX - 发布变量名和YYYY - 来自网页的字段数据....所以我不能一个一个地计算/写...
如何通过post变量,使用AJAX和点击按钮提交整个表单?