Php 我可以使用<;提交表单值吗;输入类型=";按钮“/>;?
我正在开发一个搜索引擎,我对Php 我可以使用<;提交表单值吗;输入类型=";按钮“/>;?,php,ajax,post,button,get,Php,Ajax,Post,Button,Get,我正在开发一个搜索引擎,我对GET和POST方法有一个非常严重的问题 我使用来避免每次按下按钮时页面刷新 按下按钮后,我会显示一个结果(谷歌地图、monumet图片、规格) 现在的问题是,我想通过按下这个按钮提交并显示表单值+结果(谷歌地图、monumet图片、规格) 这是一个问题,因为没有提交表单值,我真的被卡住了。当然,这里有一个工作示例供您使用: onClick="document.getElementById('FormName').submit();" index.php <!
GET
和POST
方法有一个非常严重的问题
我使用
来避免每次按下按钮时页面刷新
按下按钮后,我会显示一个结果(谷歌地图、monumet图片、规格)
现在的问题是,我想通过按下这个按钮提交并显示表单值+结果(谷歌地图、monumet图片、规格)
这是一个问题,因为
没有提交表单值,我真的被卡住了。当然,这里有一个工作示例供您使用:
onClick="document.getElementById('FormName').submit();"
index.php
<!DOCTYPE html>
<html>
<head>
<title>Working Example</title>
</head>
<body>
<form id="search-form">
<input type="text" name="text1" id="text1" value=""><br>
<input type="text" name="text2" id="text2" value=""><br>
<input type="text" name="text3" id="text3" value=""><br>
<input type="button" id="search-button" name="search-button" value="search">
</form>
<div id="response"></div>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
$('#search-button').click(function(){
$.ajax( {
type: "GET",
url: 'response.php',
data: $('#search-form').serialize(),
success: function(response) {
$('#response').html(response);
}
} );
});
});
</script>
</body>
</html>
<?php
echo "text1: " . $_GET['text1'] . "<br>";
echo "text2: " . $_GET['text2'] . "<br>";
echo "text3: " . $_GET['text3'] . "<br>";
echo "your response ...";
工作示例
$(文档).ready(函数(){
$(“#搜索按钮”)。单击(函数(){
$.ajax({
键入:“获取”,
url:'response.php',
数据:$(“#搜索表单”).serialize(),
成功:功能(响应){
$('#response').html(response);
}
} );
});
});
response.php
<!DOCTYPE html>
<html>
<head>
<title>Working Example</title>
</head>
<body>
<form id="search-form">
<input type="text" name="text1" id="text1" value=""><br>
<input type="text" name="text2" id="text2" value=""><br>
<input type="text" name="text3" id="text3" value=""><br>
<input type="button" id="search-button" name="search-button" value="search">
</form>
<div id="response"></div>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
$('#search-button').click(function(){
$.ajax( {
type: "GET",
url: 'response.php',
data: $('#search-form').serialize(),
success: function(response) {
$('#response').html(response);
}
} );
});
});
</script>
</body>
</html>
<?php
echo "text1: " . $_GET['text1'] . "<br>";
echo "text2: " . $_GET['text2'] . "<br>";
echo "text3: " . $_GET['text3'] . "<br>";
echo "your response ...";
使用javascript document.getElementById(“myform”).submit()
问题是,如果按钮设置为onMouseUp=“getScriptPage('count\u display'、'text\u content'、'1'),我已经在使用javascript了。是否可以同时调用javascript函数?onMouseUp=“getScriptPage('count_display'、'text_content'、'1');script_page2(…);“我已经在使用onMouseUp=“getScriptPage('count_display'、'text_content'、'1')”…我可以在相同的输入中使用onclick和onMouseUp吗?@AntreasApostolou自己尝试一下,然后写下这篇评论……谢谢arielcr,你能给我发一个你刚刚发给我的代码的工作示例吗?因为我试过我自己,我想我做错了什么,我用一个有效的例子编辑了答案。我想告诉您,您可以对ajax响应使用任何事件,我使用按钮的单击事件作为示例。希望有帮助!非常感谢你,你是最棒的…你肯定能救我一天…:-)