如何进行div刷新,比如10秒后执行run_query()函数而不点击按钮?
<script src="scripts/ajax.js" type="text/javascript"></script>
<div id="quote"><strong>Quote of the Day</strong></div>
<div><a style="cursor:pointer" onclick="run_query()">Next quote …</a></div>
Run Code Online (Sandbox Code Playgroud) 这个javascript函数(checkValidity)是否正确?
function checkTextBox(textBox)
{
if (!checkValidity(textBox.getValue()))
displayError("Error title", "Error message", textBox);
textBox.focus();
}
function checkValidity(e)
{
var email;
email = "/^[^@]+@[^@]+.[a-z]{2,}$/i";
if (!e.match(email)){
return false;
else
return true;
}
}
Run Code Online (Sandbox Code Playgroud)
编辑:所有的答案赞赏!谢谢!
而不是整个页面刷新一段时间后,我只是喜欢一个特定的div容器来重新加载/刷新.有没有办法做到这一点?
<div id="wrapper">
<div id="quoteContainer"></div>
</div>
Run Code Online (Sandbox Code Playgroud) 而不是通常的垂直表数据布局,如下所示:
alt text http://img62.imageshack.us/img62/2545/verticaltables.jpg
我想在css中这样显示它:
alt text http://img100.imageshack.us/img100/4144/horizontaltable.jpg
有任何想法吗?
我的php/html代码:
<div class="center_div">
<table>
<tr>
<th>Author</th>
<th>Quotes</th>
<th>Arabic</th>
<th>Reference</th>
</tr>
<?php while ($row= mysql_fetch_array($result)) { ?>
<tr>
<td width="150"><?php h($row['vAuthor']) ?></td>
<td><?php h($row['cQuotes']) ?></td>
<td><?php h($row['cArabic']) ?></td>
<td><?php h($row['vReference']) ?></td>
</tr>
<?php } ?>
</table>
</div></div>
Run Code Online (Sandbox Code Playgroud) 我正在使用此函数来突出显示mysql查询的结果:
function highlightWords($string, $word)
{
$string = str_replace($word, "<span class='highlight'>".$word."</span>", $string);
/*** return the highlighted string ***/
return $string;
}
....
$cQuote = highlightWords(htmlspecialchars($row['cQuotes']), $search_result);
Run Code Online (Sandbox Code Playgroud)
问题是,如果我输入'good',它只会显示我的搜索结果,小写'g'ood而不是'Good'.我该怎么纠正这个?
我需要一个url正则表达式,用于验证url字符串没有 http://www. 或https://www.
有任何想法吗?
当用户输入搜索词时,我正在使用jQuery从php类加载搜索结果.问题是jQuery在主页面上第一次运行并执行所需的函数,但是当用户输入搜索关键字并且结果是通过ajax从同一页面上的类文件加载时,jQuery不会执行功能要求.
我想要做的是,当搜索结果加载到主页面时,它应该只显示引用和作者,而不是阿拉伯语和引用.当用户点击Quote时,它应该像手风琴一样,切换阿拉伯语和引用的div容器.
但是,虽然jQuery可以很好地加载类文件的结果,但是当它加载搜索结果时它不会执行以隐藏阿拉伯语和引用的容器,也不会在用户单击引用以显示时执行click事件.容器,如萤火虫所示.
index.php文件:
<script type="text/javascript">
$(function() {
$(".bsearch")
.keydown(function() {
//create post data
var postData = {
"search" : $(this).val()
};
//make the call
$.ajax({
type: "POST",
url: "quotes_in.php",
data: postData, //send it along with your call
success: function(response){
$("#left").html(response);
}
});
}),
$("div#smore").hide();
//toggle the componenet with class msg_body
$("p#s_quotes").click(function()
{
$(this).next("div#smore").slideToggle(200);
}),
});
</script>
<!-- Begin Left Column -->
<div id="left">
</div>
<!-- End Left Column -->
Run Code Online (Sandbox Code Playgroud)
Quotes_in.php:
include_once "inc/class.quotes.inc.php";
$quotes = new Quotes($db);
if (isset($_POST['search']))
$quotes->searchQuotes(); …Run Code Online (Sandbox Code Playgroud) 默认情况下会选中复选框.如果未选中,则应隐藏文本.我如何在jquery中隐藏或显示文本?
HTML:
<div class="check">
<p><input type="checkbox" value="Name" id="name" checked /> <label for="name">Name</label></p>
<p><input type="checkbox" value="Reference " id="reference" checked /> <label for="reference">Reference</label></p>
</div>
<div id="nametxt"> Show Name TEXT </div>
<div id="reftxt"> Show Ref TEXT </div>
Run Code Online (Sandbox Code Playgroud) 我正在使用php domdocument将数据插入到xml文件中.但是当我打开xml文件时,数据显示在一行中:
<?xml version="1.0"?>
<root><activity>swimming</activity><activity>jogging</activity></root>
Run Code Online (Sandbox Code Playgroud)
我如何以编程方式对齐它?
<?xml version="1.0"?>
<root>
<activity>swimming</activity>
<activity>jogging</activity>
</root>
Run Code Online (Sandbox Code Playgroud) 我在goddady上托管我的域名,并且我试图在数据库中散列密码.但是,它会抛出错误:
MySQL said:
#1305 - FUNCTION dbname.SHA2 does not exist
Run Code Online (Sandbox Code Playgroud)
这是我用来在数据库中插入数据的命令.
insert into `dbname`.`tbl_members` values ('1', 'admin', SHA2('password', 224));
Run Code Online (Sandbox Code Playgroud)
当我在本地服务器上执行它时,这完全正常.
html ×4
javascript ×3
jquery ×3
php ×3
css ×2
ajax ×1
checkbox ×1
domdocument ×1
hash ×1
highlight ×1
html-table ×1
mysql ×1
refresh ×1
regex ×1
search ×1
url ×1
validation ×1
xml ×1