我已经通过数据库的Django模型,在那里创建status和id和username是表的字段Messages.
我需要计算status value= 0特定行的行数username.
这是我不完整的代码:
Message_me = Messages.objects.get(username='myname')
Run Code Online (Sandbox Code Playgroud) 我的代码如下:
$('.summaryT').keypress(function(e){
if(e.which == 13){
callajax();
$(this).focusout();
}
});
Run Code Online (Sandbox Code Playgroud)
正如您在上面的代码中看到的,当用户按下回车键时,首先callajax()运行(正常工作).之后我想从.summaryT输入框中集中注意力,我该如何实现这一目标?
我使用下面的代码来切换td颜色
<html>
<head>
<script class="jsbin" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script>
$(function(){
$("td").click(function(){
$(this).addClass("on").parent().siblings("tr").find("td").removeClass("on");
});
});
</script>
<style>
article, aside, figure, footer, header, hgroup,
menu, nav, section { display: block; }
.on { background-color:red; color:#ffffff; }
</style>
</head>
<body>
<table class="mytable" border=1>
<tbody>
<tr>
<td>Hello World</td>
<td>Hello World1</td>
<td>Hello World2</td>
</tr>
<tr>
<td>Hello World</td>
<td>Hello World1</td>
<td>Hello World2</td>
</tr>
<tr>
<td>Hello World</td>
<td>Hello World1</td>
<td>Hello World2</td>
</tr>
</tbody>
</table>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
但现在我需要做三件事,
这是我的问题,我tuple1=[(1, 3), (3, 2), (2, 1)]想根据每个元组的最后一位数排序元组,所以结果将
output=[(2, 1), (3, 2), (1, 3)]
如下所示是我的代码
i=0
for x in tuples:
c.append(x[len(x)-1])
last=sorted(c)
for y in last.iteritems():
if(y in x[len(x)-1]):
print x
#b.insert(i,x)
i=i+1
Run Code Online (Sandbox Code Playgroud)
运行iam后收到错误消息
Traceback (most recent call last):
File "x.py", line 47, in <module>
sort_last([(1, 3), (3, 2), (2, 1)])
File "x.py", line 35, in sort_last
if(y in x[len(x)-1]):
TypeError: argument of type 'int' is not iterable
Run Code Online (Sandbox Code Playgroud) 我正在尝试使用直接管理在 vps 上安装 Laravel。下面是我的 Apache 配置文件
<VirtualHost MYIP:80 >
ServerName www.domain.com
ServerAlias www.domain.com domain.com
ServerAdmin webmaster@chat.am
DocumentRoot /home/mydir/domains/domain.com/public_html
ScriptAlias /cgi-bin/ /home/mydir/domains/domain.com/public_html/cgi-bin/
UseCanonicalName OFF
<IfModule !mod_ruid2.c>
SuexecUserGroup mydir mydir
</IfModule>
CustomLog /var/log/httpd/domains/domain.com.bytes bytes
CustomLog /var/log/httpd/domains/domain.com.log combined
ErrorLog /var/log/httpd/domains/domain.com.error.log
<Directory /home/mydir/domains/domain.com/public_html>
php_admin_flag safe_mode OFF
php_admin_flag engine ON
php_admin_value sendmail_path '/usr/sbin/sendmail -t -i -f chat$
php_admin_value mail.log /home/mydir/.php/php-mail.log
php_admin_value open_basedir /home/mydir/:/tmp:/var/tmp:/usr/loc$
</Directory>
</VirtualHost>
Run Code Online (Sandbox Code Playgroud)
根据 Laravel 手册,我必须指向该public目录。设置为后,doc root当/home/mydir/domains/domain.com/public_html/public我尝试访问时出现此错误domain.com
500内部服务器错误
更新:/var/log/httpd/domains/domain.com.error.log包含此 Laravel 错误
PHP 解析错误:语法错误,/home/mydir/domains/domain.com/public_html/vendor/laravel/framework/src/Illuminate/Support/helpers.php 第 …
以下是我的表格代码:
class FMessage(forms.Form):
From = forms.CharField()
To = forms.CharField()
Subject = forms.CharField()
Message = forms.CharField()
Run Code Online (Sandbox Code Playgroud)
这是我的HTML代码:
<form method='POST' action='.'>
{% csrf_token %}
{{ form.as_p }}
<input type='submit' value='submit'>
</form>
Run Code Online (Sandbox Code Playgroud)
代码通过显示表单工作正常,并且在功能上没有任何问题,但现在我需要将表单字段包装在html中,div如下所示:
<div id='mydiv'>
<input ... />
<div>
Run Code Online (Sandbox Code Playgroud)
我该如何解决?
这是我的代码:
$(val1).mouseleave(function () {
flag = false;
$(val3 + "," + val4).mouseenter(function () {
flag = true;
//alert(flag);
});
if (flag == true) {
//alert("if"+flag);
$(".big" + i + j + "boxer").show();
$(".big" + i + "box").show();
$(".big" + i + "box").append('<div class="opacity" style="background-color:rgba(00,00,00,0.77);position:absolute;top:0;right:0;left:0;bottom:0;"></div>')
$(".small" + i + "box").append('<div class="opacity" style="background-color:rgba(00,00,00,0.77);position:absolute;top:0;right:0;left:0;bottom:0;"></div>')
} else {
//alert("else"+flag);
$('.opacity').remove();
$(val2).hide();
$(val3).show();
}
});
Run Code Online (Sandbox Code Playgroud)
这不符合flag = true条件.如果我alert在内$(val1).mouseleave(function(){});,它表明 flag = true; 但是当我在外面发出警报时$(val1).mouseleave(function(){});,它会显示出来flag = false. …
这是我的代码..
@foreach (Session::get('show_my_data') as $key1 => $value1)
<div class="sb_li">
<input id="sb_system_input_{{ $value1->Myid }}" class="fr_cap" type="text" disabled name="fr_cap[{{ $value1->Myid }}]" value="{{ $value1->FRCapacity }}" maxlength="127"/>
</div>
@foreach ($m002_siteinfo as $key => $value)
@if({{!$value1->name}})
<div class="sb_li">
<input id="sb_system_input_{{ $value->Myid }}" class="fr_cap" type="text" disabled name="fr_cap[{{ $value->Myid }}]" value="" maxlength="127"/>
</div>
@endif
@endforeach
@endforeach
Run Code Online (Sandbox Code Playgroud)
我试图显示Second foreach其中没有在 中间first foreach使用的值if condition,但我进入syntax errorLaravel,Blade模板..任何方法来解决这个问题?
你好,这里的人是我的代码......
$ (".input_check").change (function (){
if ($ (this).is (':checked')) {
console.log(this.id + 'is checked')
} else {
console.log(this.id + 'is not checked')
}
});
Run Code Online (Sandbox Code Playgroud)
上面的代码适用于几个复选框....但我想在页面加载后不执行检查$ (".input_check").change....我试过...
$ (function () {
if ($ (".input_check").is (':checked')) {
console.log(this.id + 'is checked')
}
)}
Run Code Online (Sandbox Code Playgroud)
荫试图找到ID this.id而不是wrking ..我也试过(this).id和this.attr("id")仍然没有工作... :(我得到undefined反正来解决这个问题?
UPDATE :: I have multiple checkboxes which are checked... I am trying to find multiple ids of those check boxes which are checked
这是我的代码
for ($i=0; $i<$Percentile["Parameter_length"]; $i++)
{
echo "Eqt_Param".$i."=".$Percentile["Eqt_Param".$i];
}
Run Code Online (Sandbox Code Playgroud)
以上代码将显示
Eqt_Param0=2.00
Eqt_Param1=3.00
Eqt_Param2=1.00
Eqt_Param3=5.00
Run Code Online (Sandbox Code Playgroud)
如果我放在echo()for循环之外,我需要相同的结果.请帮我解决这个问题......
这是我的代码,
var mapForm = document.createElement("form");
mapForm.target = "_blank";
mapForm.method = "POST";
mapForm.action = "delete";
// Create an input
var mapInput = document.createElement("input");
mapInput.type = "hidden";
mapInput.name = "uploaded";
mapInput.value = file.name;
// Add the input to the form
mapForm.appendChild(mapInput);
// Add the form to dom
document.body.appendChild(mapForm);
// Just submit
mapForm.submit();
Run Code Online (Sandbox Code Playgroud)
它确实有效,但在提交值后,它会在一个新窗口中打开动作URL,因为我已经给出了mapForm.target = "_blank";,是否可以在不打开任何窗口的情况下提交表单我的意思是它应该保留在同一个窗口但它不应该去"删除页面"?,而不是使用ajax ...
我需要找到给定范围内的最高素数.
这是我的代码,适用于0-100,但如果我给0-125,它显示素数为125.
<?php
$flag=0;
$b=125;
for($i=$b;$i>=0;$i--)
{
if($i%2!=0)
{
for($b=3;$b<10;$b++)
{
if($flag==0)
{
echo('<br>');
if($i%$b!=0)
{
echo('highest prime number is'.$i);
$flag=1;
break;
}
elseif ($i%$b==0)
{
break;
}
}
}
}
}
?>
Run Code Online (Sandbox Code Playgroud)
在上面的代码中,我的范围是0-125
我试图找到数组中奇数最低的数字.
这是我的代码:
$a=array(81,10,6,71,13,61,8,16,0,9,12);
$b=count($a);
for($i=0;$i<$b;$i++)
{
if($a[$i]/2!=0)
{
$flag=0;
for($j=0;$j<$b;$j++)
{
if($a[$j]<=$a[$i] and $a[$j]/2!=0)
{
$a[$i]=$a[$j];
$flag=1;
}
}
if($flag==1)
{
echo('lowest odd number is'.$a[$i]);
}
break;
}
break;
}
Run Code Online (Sandbox Code Playgroud)
我不是在寻找新的逻辑我只是想在上面的代码中找到一个错误.为什么不起作用?
php ×6
html ×5
javascript ×5
jquery ×4
arrays ×3
css ×2
django ×2
laravel ×2
python ×2
.htaccess ×1
apache ×1
blade ×1
dictionary ×1
django-forms ×1
function ×1
httpd.conf ×1
if-statement ×1
jquery-ui ×1
laravel-3 ×1
laravel-4 ×1
list ×1
primes ×1
terminal ×1
tuples ×1