Javascript 在模式对话框/对话框中显示搜索结果
我似乎无法让我的模态框显示搜索结果,我可以提交表单,模态框将出现,我尝试在模态框中回显我的变量,但没有显示。我试着把搜索脚本和脚本放在模式框中。没有什么。我已经尝试了几乎所有我能找到的模态盒,所以不是模态盒,我只是做得不对。我只知道我累了,我的眼睛受伤了,我正要放弃做这件事。我只是不想在搜索时刷新页面,因为它会清除用户在搜索模型id时输入的所有值。为了创建一个生物,您必须拥有不容易找到的模型id。我正在尝试提供要搜索的模型id副本。请谢谢你的帮助 表格Javascript 在模式对话框/对话框中显示搜索结果,javascript,php,jquery,html,modal-dialog,Javascript,Php,Jquery,Html,Modal Dialog,我似乎无法让我的模态框显示搜索结果,我可以提交表单,模态框将出现,我尝试在模态框中回显我的变量,但没有显示。我试着把搜索脚本和脚本放在模式框中。没有什么。我已经尝试了几乎所有我能找到的模态盒,所以不是模态盒,我只是做得不对。我只知道我累了,我的眼睛受伤了,我正要放弃做这件事。我只是不想在搜索时刷新页面,因为它会清除用户在搜索模型id时输入的所有值。为了创建一个生物,您必须拥有不容易找到的模型id。我正在尝试提供要搜索的模型id副本。请谢谢你的帮助 表格 // My form <fo
// My form
<form name="Form2" method="get" action="" enctype="application/x-www-form-urlencoded" id="Form2">
<input type="text" id="Editbox19" style="position:absolute;left:20px;top:80px;width:191px;height:35px;line-height:35px;z-index:0;" name="name" value="" class"rounded">
<div id="wb_Text25" style="position:absolute;left:20px;top:134px;width:58px;height:34px;z-index:1;text-align:left;">
<span style="color:#FFFFFF;font-family:Arial;font-size:15px;">Entry ID:</span></div>
<input type="text" id="Editbox20" style="position:absolute;left:20px;top:153px;width:191px;height:35px;line-height:35px;z-index:2;" name="entry" value=""class"rounded">
<div id="wb_Image2" style="position:absolute;left:10px;top:5px;width:221px;height:31px;z-index:3;">
<img src="images/modelid.png" id="Image2" alt=""></div>
<div id="wb_Text24" style="position:absolute;left:18px;top:46px;width:227px;height:34px;z-index:4;text-align:left;">
<span style="color:#FFFFFF;font-family:Arial;font-size:15px;"><br> Name:</span></div>
<input type="submit" id="Button1" onclick="$('#jQueryDialog1').dialog('open');return false;" name="" value="Submit" style="position:absolute;left:269px;top:187px;width:96px;height:25px;z-index:2;">// What activates the Modal Box
</form>
//我的表单
条目ID:
姓名:
//什么激活模式框
模式框
//Modal Box itself
<div id="jQueryDialog1" style="z-index:3;" title="This is the title">
//Modal Box Content where I want to display Search results.
</div>
</div>
//模态框本身
//要在其中显示搜索结果的模式框内容。
我的脚本:
// Modal Box Script
<script>
$(document).ready(function()
{
var jQueryDialog1Opts =
{
width: 554,
height: 367,
position: { my: 'center', at: 'center', of: window },
resizable: true,
draggable: true,
closeOnEscape: true,
autoOpen: false
};
$("#jQueryDialog1").dialog(jQueryDialog1Opts);
});
</script>
//模式框脚本
$(文档).ready(函数()
{
变量jQueryDialog1Opts=
{
宽度:554,
身高:367,
位置:{my:'center',at:'center',of:window},
可调整大小:正确,
真的,
closeOnEscape:没错,
自动打开:错误
};
$(“#jQueryDialog1”)。对话框(jQueryDialog1Opts);
});
我的搜索脚本:
<?php
if(isset($_GET['name'], $_GET['entry'])) {
try {
$host = "xxxxxx";
$user = "xxxxxxxx";
$password = "xxxxxx";
$database_name = "xxxxxxxx";
$dbh = new PDO("mysql:host=$host;dbname=$database_name", $user, $password, array(
//PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION
));
$conditions = array();
$oemSearch = $_GET['name'];
$oempnSearch = $_GET['entry'];
$min = 1;
$oemLen = strlen($oemSearch);
$oempnLen = strlen($oempnSearch);
if ($oemSearch == "" && $oempnSearch == "") {
echo "You must enter a Name or Entry ID";
exit;
}
if ($oemSearch != "" && $oemLen < $min) {
echo "You must enter an Entry ID of atleast 1 Character.";
exit;
}
if ($oempnSearch != "" && $oempnLen < $min) {
echo "You must enter at least 3 P/N characters.";
exit;
}
if ($oemSearch != "" && $oempnSearch == "") {
$stmt = $dbh->prepare("select * from creature_template WHERE name LIKE '%$oemSearch%' ORDER BY entry LIMIT :limit OFFSET :offset");
//$query->bindValue(1, "%$oemSearch%", PDO::PARAM_STR);
}
if ($oemSearch == "" && $oempnSearch != "") {
$stmt = $dbh->prepare("select * from creature_template WHERE name LIKE '%$oempnSearch%' ORDER BY entry LIMIT :limit OFFSET :offset");
//$query->bindValue(1, "%$oemSearch%", PDO::PARAM_STR);
}
if ($oemSearch != "" && $oempnSearch != "") {
$stmt = $dbh->prepare("select * from creature_template WHERE name LIKE '%$oemSearch%' OR entry LIKE '%$oempnSearch%' ORDER BY entry LIMIT :limit OFFSET :offset");
//$query->bindValue(1, "%$oemSearch%", PDO::PARAM_STR);
}
// Find out how many items are in the table
$total = $dbh->query("SELECT COUNT(*) AS num FROM creature_template ")->fetchColumn();
// How many items to list per page
$limit = 10;
// How many pages will there be
$pages = ceil($total / $limit);
// What page are we currently on?
$page = min($pages, filter_input(INPUT_GET, 'page', FILTER_VALIDATE_INT, array(
'options' => array(
'default' => 1,
'min_range' => 1,
),
)));
// Calculate the offset for the query
$offset = ($page - 1) * $limit;
// Some information to display to the user
$start = $offset + 1;
$end = min(($offset + $limit), $total);
// Bind the query params
$stmt->bindParam(':limit', $limit, PDO::PARAM_INT);
$stmt->bindParam(':offset', $offset, PDO::PARAM_INT);
$stmt->execute();
// Do we have any results?
if ($stmt->rowCount() > 0) {
// Define how we want to fetch the results
$stmt->setFetchMode(PDO::FETCH_ASSOC);
$iterator = new IteratorIterator($stmt);
// Display the results
echo "<table class='views-table' border=1>";
echo "<tr class='tblheader'><th bgcolor=#00CC00>Name</th><th bgcolor=#00CC00>Entry ID</th><th bgcolor=#00CC00>Model ID</th></tr>";
foreach ($iterator as $row) {
echo "<tr class=odd views-row-first1><td><a href=http://wowhead.com/npc=";
echo $row['entry'];
echo "></td><td><b>";
echo $row['entry'];
echo "</a></td><td><b>";
echo $row['modelid1'];
echo "</td></tr></b>";
}
echo "</table>";
} else {
echo '<p>No results could be displayed.</p>';
}
} catch (Exception $e) {
echo '<p>', $e->getMessage(), '</p>';
}}
?>
您是否在使用ajax?从按钮中删除onclick
,然后尝试:
$("#Button1").click(function(){
var name = document.getElementById("Editbox19");
var entry = document.getElementById("Editbox20");
var jQueryDialog1Opts =
{
width: 554,
height: 367,
position: { my: 'center', at: 'center', of: window },
resizable: true,
draggable: true,
closeOnEscape: true,
autoOpen: false
};
$.ajax({
url: "search.php?name="+name+"&entry="+entry,
type: "GET",
success:function(data){
$("#jQueryDialog1").dialog(jQueryDialog1Opts);
$("#jQueryDialog1").html(data);
},
error:function (){
alert("Error!!! Please refresh the page and try again!");
}
});
});
我假设您的搜索脚本位于名为“search.php”的php页面中。相应地更改它是的。你到底在使用ajax吗?从按钮中删除onclick
,然后尝试:
$("#Button1").click(function(){
var name = document.getElementById("Editbox19");
var entry = document.getElementById("Editbox20");
var jQueryDialog1Opts =
{
width: 554,
height: 367,
position: { my: 'center', at: 'center', of: window },
resizable: true,
draggable: true,
closeOnEscape: true,
autoOpen: false
};
$.ajax({
url: "search.php?name="+name+"&entry="+entry,
type: "GET",
success:function(data){
$("#jQueryDialog1").dialog(jQueryDialog1Opts);
$("#jQueryDialog1").html(data);
},
error:function (){
alert("Error!!! Please refresh the page and try again!");
}
});
});
我假设您的搜索脚本位于名为“search.php”的php页面中。相应地更改它是的。你需要jquery/ajax来启动,这是你的答案你需要jquery/ajax来启动,这是你的答案我在表单上方添加了脚本,经过测试,什么都没有发生。D:非常感谢!您是否用您自己的脚本替换了它,而您有//模式框脚本
?你能看看你的控制台并告诉我你得到了什么错误吗?我替换了我的脚本是的。你说我的控制台是什么意思?没有抛出错误。好的,很好。确保它们包装在$(文档)中。准备就绪(函数(){
也一样。如果您使用的是chrome:右键单击>检查元素>控制台。您在单击提交之前/之后看到了什么吗?我将$(文档)放入。准备就绪(函数(){在$(“#按钮1”)之前)。单击(函数(){是这样吗?我在表单上方添加了脚本,并进行了测试,什么都没有发生。D:非常感谢!您是否用自己的脚本替换了您的//Modal Box script
?您能看看您的控制台并告诉我您遇到了什么错误吗?我替换了我的脚本是的。您是指我的控制台吗?没有错误抛出。好的,很好。确保它们被包装在$(文档)中。准备好(函数(){
。如果您使用的是chrome:Right click>Inspect element>Console。在单击submit之前/之后看到任何内容吗?我将$(文档)放入。准备好(函数(){在$(“#按钮1”)之前)。单击(函数(){对吗?