if(){}else
{
echo "<script>
$(document).ready(function() {$('.captcha').hide(); });
</script>";
......php代码,在此省略
}我想要的结果是当执行else的时候页面中的captcha class的css给隐藏掉。但如上写的代码貌似不对,该怎么在php的判断语句中加jquery代码啊?
{
echo "<script>
$(document).ready(function() {$('.captcha').hide(); });
</script>";
......php代码,在此省略
}我想要的结果是当执行else的时候页面中的captcha class的css给隐藏掉。但如上写的代码貌似不对,该怎么在php的判断语句中加jquery代码啊?
解决方案 »
- 一个关于文件上传的页面.遇到错误.求大神指导指导
- PHP如何调用WinHttpRequest?
- 感觉是正确的语句不知那里出了问题,得不到结果。。。求助
- 我想学PHP 不知道用什么工具
- 一个正则表达式的问题 急用!
- PHP的fopen()函数给出的几种文件模式中的读模式和读写模式到底有什么区别?
- binary让我心痛的感觉
- 怎样实现字数统计?
- 我装上apache_2.0.43后,输入http://localhost:端口/不能运行(有人说是端口冲突,我改成别的端口还是不行),还有什么地方容易出错,请高手明
- 大家帮忙看一下,问问多多.(高手请进)
- 问大家一个gbk和gb2312的问题
- maven打包android项目结构问题
{
echo "<script>
(function($){
$('.captcha').show();
})(jQuery);
</script>";
$error_msg = elgg_echo('loginerror');当执行else语句的时候希望能执行上面的jquery代码,该怎么写?
echo <<<HTML
<script>
(function($){
$('.captcha').show();
})(jQuery);
</script>
HTML;
$error_msg = elgg_echo('loginerror');
不过记得,这个输出必须在你的captcha已经正常输出之后进行控制,否则无效。
else
{
echo "<script>
$('.captcha').show();
</script>";
php代码
}
if(){}else
?>
<script>//jquery</script>
<?php
}
?>
{
?>
<script>
$('.captcha').show();
</script>";
<?php
php代码
?>
这么写也不对啊
问题关键在于,最终输出到客户端的html代码是怎样的
{
?>
<script>
$('.captcha').show();
</script>
<?php 这样也不行啊
echo '<input type="hidden" id="fool" value="false">';在整个页面载入之后再根据这个值来执行相应的操作。
$(document).ready(function() {
if ($('#fool').val()=='false'){
//执行代码
$('.captcha').show();
}
});
这句没理解,什么意思啊?不过我加了如下这段也不行
else
{
echo '<input type="hidden" id="fool" value="false">';
?><script>
$(document).ready(function() {
if ($('#fool').val()=='false'){
//执行代码
$('.captcha').show();
}
});
</script>
<?php
php代码
?>
{
system_message(elgg_echo('loginok'));
if (isset($_SESSION['last_forward_from']) && $_SESSION['last_forward_from'])
{
$forward_url = $_SESSION['last_forward_from'];
unset($_SESSION['last_forward_from']);
forward($forward_url);
}
else
{
if ( (isadminloggedin()) && (!datalist_get('first_admin_login')))
{
system_message(elgg_echo('firstadminlogininstructions'));
datalist_set('first_admin_login', time()); forward('pg/admin/plugins');
}
else if (get_input('returntoreferer'))
{
forward($_SERVER['HTTP_REFERER']);
}
else
{
forward("pg/dashboard/");
}
}
}
else
{
?>
<script>
$('.captcha').show();
</script>
<?php
$error_msg = elgg_echo('loginerror');
// figure out why the login failed
if (!empty($username) && !empty($password)) {
// See if it exists and is disabled
$access_status = access_get_show_hidden_status();
}
else
{
$value = "value";
setcookie("test",$value);然后在view页里
<script type="text/javascript">
$(document).ready(function() {
$('input[name=username]').focus();
$('.captcha').hide();
if ($_COOKIE.val()=='value'){
$('.captcha').show();
}
});
</script>上面写的对不对,如果有语法错误,请帮忙纠正,谢谢
<script src="jquery-1.4.2.js"></script>
<div id="dv" style="display:none;width:100px;height:100px;border:1px solid red"></div>
<?php
$k='<script>
$(function(){
$("#dv").show(3000);
})
</script>';
$do=DOMDocument::loadHTML($k);
echo $do->saveHTML();
?>
</html>
else
{
$value = "value";
setcookie("test",$value);然后在view页里
<script type="text/javascript">
$(document).ready(function() {
$('input[name=username]').focus();
$('.captcha').hide();
if ($_COOKIE.val()=='value'){
$('.captcha').show();
}
});
</script>上面写的对不对,如果有语法错误,请帮忙纠正,谢谢
if ($_COOKIE.val()=='value'){ js里没有这么写的变量吧?$_COOKIE . 其实对不对你在firefox里用firebug调试一下就知道了。
$(document).ready(function() {
$('input[name=username]').focus();
$('.captcha').hide();
var cookies=document.cookie; if (cookies =='value'){
$('.captcha').show();
}
});
</script>我这么写了,在firebug上没有报错,但是那个captcha没有show出来
{
$value = "value";
setcookie("test",$value);这里我设置了一个cookie
然后在view里
<script type="text/javascript">
$(document).ready(function() {
$('input[name=username]').focus();
$('.captcha').hide();
var cookies=document.cookie;if (cookies == 'value'){
$('.captcha').show();
}
});
</script>
这么写,请问写的哪里不对,为什么当代码执行到逻辑判断else的时候那个captcha不显示出来?
就算你的cookie 有内容吧
if (cookies == 'value') 这里怎么是这样判断呢.
getCookie('Id')//获取cookie的值...一塌糊涂啊....http://www.satya-weblog.com/2007/05/php-and-javascript-cookie.html先看看基本的东西.先仔细的学习一下cookie 在php和js里的用法.