如何使用select2在输入框上设置默认值?这是我的HTML
<input type="text" id="itemId0" value="Item no. 1">
Run Code Online (Sandbox Code Playgroud)
和我的javascript:
$("#itemId0").select2({
placeholder: 'Select a product',
formatResult: productFormatResult,
formatSelection: productFormatSelection,
dropdownClass: 'bigdrop',
escapeMarkup: function(m) { return m; },
minimumInputLength:1,
ajax: {
url: '/api/productSearch',
dataType: 'json',
data: function(term, page) {
return {
q: term
};
},
results: function(data, page) {
return {results:data};
}
}
});
function productFormatResult(product) {
var html = "<table><tr>";
html += "<td>";
html += product.itemName ;
html += "</td></tr></table>";
return html;
}
function productFormatSelection(product) {
var selected = "<input type='hidden' name='itemId' …Run Code Online (Sandbox Code Playgroud) 我有使用Codeigniter编写的系统和使用MySQL的数据库.系统具有用户,具有不同权限的用户组等.拥有许多具有多对多关系的mysql表.
我有一些表:
目前,我正在记录用户所做的这些表的数据的每个更改.用户可以根据其权限更改这些数据.存储日志的更改只是简单的形式
A user changed product features with id of A8767
B user added new customer with id 56
C user edited content of orderlist
A user added new product (id: A8767) to order (id: or67)
...
Run Code Online (Sandbox Code Playgroud)
我希望保留所有对每个细节所做的更改,例如编辑Stackoverflow问题的历史记录.我可以考虑log_table设计以保持各种表的所有数据更改.有没有办法,教程,引擎,插件来做到这一点?只有我能想到制作每张桌子的副本并继续存储它们的变化,但我不认为它的好方法.
我在以下URL有一个images文件夹.
www.mysite.com/uploads/
Run Code Online (Sandbox Code Playgroud)
在另一页上:
www.mysite.com/search.php/
Run Code Online (Sandbox Code Playgroud)
我试图访问图像,其中,使用正确的标签链接,但我得到:
Forbidden
You don't have permission to access /uploads/ on this server.
Run Code Online (Sandbox Code Playgroud)
所以我开始涉足一个.htaccess文件,我不知道我在做什么,我试着查看一些文档,但没有运气,我甚至举了另一个问题的例子.这就是我的.htaccess文件看起来如何:
<FilesMatch "\.(gif|jpe?g|png)$">
Order allow,deny
Allow from all
</FilesMatch>
<Directory /uploads>
# All access controls and authentication are disabled
# in this directory
Satisfy Any
Allow from all
</Directory>
Run Code Online (Sandbox Code Playgroud)
关于我如何拥有它的任何想法都允许访问该文件夹?
我试图扩展PHP类而不重写整个事情.这是一个例子:
<?
$a = new foo();
print $a->xxx();
$b = new bar();
print $b->xxx();
class foo {
const something = 10;
public function xxx() {
$this->setSomething();
return $this->something;
}
private function setSomething() {
$this->something = self::something;
}
}
class bar extends foo {
public function xxx() {
$this->setSomething();
$this->something++;
return $this->something;
}
}
?>
Run Code Online (Sandbox Code Playgroud)
但是当我运行脚本时,我收到以下错误:
Fatal error: Call to private method foo::setSomething() from context 'bar' in test.php on line 23
Run Code Online (Sandbox Code Playgroud)
似乎bar不继承私有函数setSomething().如何在不修改foo类的情况下解决这个问题?
我有查询:
SELECT * FROM `users`
WHERE (`firstname` LIKE 'Luke' AND `lastname` LIKE 'Skywalker') OR
(`firstname` LIKE 'Foo' AND `lastname` LIKE 'Bar') OR
(`firstname` LIKE 'Tom' AND `lastname` LIKE 'Turner');
Run Code Online (Sandbox Code Playgroud)
但我想通过使用where ... in ...来尝试使其更具可读性
SELECT * FROM users
WHERE `firstname`
IN ('Luke','Foo','Tom') AND `lastname` IN ('Skywalker','Bar','Turner');
Run Code Online (Sandbox Code Playgroud)
但不幸的是,这也将匹配"Tom Skywalker","Foo Turner"所有混合你可以想到.
我必须选择first和lastname(也许更多字段,如DOB),因为我从外部API获取数据,我必须检查这些名称是否在我们的系统中.
我有一个函数,它回应javascript导航到另一个页面.导航发生时,
echo 'window.location.href="'.$url.'";';
Run Code Online (Sandbox Code Playgroud)
不起作用,只需将其打印在屏幕上即可.
"window.location.href="./index.php";
Run Code Online (Sandbox Code Playgroud)
我用这种方式使用我的函数: redirect("./index.php");
我的php功能如下
function redirect($url)
{
if (!headers_sent())
{
header('Location: '.$url);
exit;
}
else
{
echo '<script type="text/javascript">';
echo 'window.location.href="'.$url.'";';
echo '</script>';
echo '<noscript>';
echo '<meta http-equiv="refresh" content="0;url='.$url.'" />';
echo '</noscript>'; exit;
}
}
Run Code Online (Sandbox Code Playgroud) 在一段时间里,我一直在处理分页课中的问题.
问题在于,除了第1页的链接外,所有分页都可以.
所有链接都像:
example.com/method/page/2
example.com/method/page/3
Run Code Online (Sandbox Code Playgroud)
...
但是,当我想转到第1页时,链接看起来像:
example.com/method/page/
Run Code Online (Sandbox Code Playgroud)
当然,它看起来有些尴尬.我希望它看起来像:
example.com/method/page/1
Run Code Online (Sandbox Code Playgroud)
如何在分页库中修复此问题?!
我有一个div内部的图像列表和一个jquery ui滑块,当用户滑动条形图像应该调整大小/缩放(无论你想叫它),我尝试选择所有图像并使用jquery更改css的宽度和高度.它有效,但它非常慢,不是很流畅.
我读到浏览器很难调整图像大小,但应该有一种方法可以提高性能或使其流畅,至少对于正在加载的图像.
这是我的html标记:
<div class="file-list">
<div class="file-cell">
<div class="thumb-wrapper">
<img width="100" height="100" title="mytitle" alt="myalt" src="image1.jpg">
</div>
</div>
<div class="file-cell">
<div class="thumb-wrapper">
<img width="100" height="100" title="mytitle" alt="myalt" src="image1.jpg">
</div>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
这是CSS代码:
div.file-cell {
margin: 10px;
float: left;
padding: 8px;
width: 100px;
background: none;
margin-bottom: 5px;
cursor: pointer;
}
Run Code Online (Sandbox Code Playgroud)
这是Javascript代码:
jQuery().ready(function(){
var images = jQuery('.thumb-wrapper img'); //caches the query when dom is ready
jQuery( "#slider" ).slider({
step: 13,
min: 70,
max: 200,
value: 100,
slide: function(event, ui){
//i think if …Run Code Online (Sandbox Code Playgroud) php ×4
javascript ×3
jquery ×2
mysql ×2
.htaccess ×1
apache ×1
browser ×1
class ×1
codeigniter ×1
echo ×1
inheritance ×1
jquery-ui ×1
navigation ×1
pagination ×1
performance ×1
url ×1
where-clause ×1