我正在尝试在转发器中填充下拉列表,但我不是很成功.我可能使用错误的EventArgs e.
这是我的aspx代码:
<asp:Repeater runat="server" id="criteriaScore">
<HeaderTemplate>
<ul>
<li class="header"><span class="item">Kriterie</span><span class="value">Poeng</span><span class="description">Beskrivelse</span></li>
</HeaderTemplate>
<ItemTemplate>
<li>
<span class="item"> <%# Eval("criteria") %>:</span>
<asp:DropDownList id="ddlRating" runat="server" autopostback="true" enableviewstate="false"></asp:DropDownList>
<span class="value score<%# Eval("lvl") %>" title="<%# Eval("description") %>"> </span>
</li>
</ItemTemplate>
<FooterTemplate>
</ul>
</FooterTemplate>
</asp:Repeater>
Run Code Online (Sandbox Code Playgroud)
而背后的代码:
protected void criteriaScore_ItemDataBound(object sender, DataListCommandEventArgs e)
{
DropDownList ddl = (DropDownList)e.Item.FindControl("ddlRating");
for(int i=1; i > 5; i++)
{
ddl.Items.Add(new ListItem(i.ToString(), i.ToString()));
}
}
Run Code Online (Sandbox Code Playgroud)
有人可以指导我走正确的道路吗?:)
为什么我无法while进入getCustomers()函数循环?
$stores = $bl->getStoresForGuide($gID); //Returns 6 stores
$storelist = getStoreList($stores); //Generate the HTML for the store list
$brandlist = getCustomers($stores); //Generate the HTML for brand list
function getStoreList($stores)
{
while ($row = mysql_fetch_array($stores)) {
// Do stuff
}
//return result
}
function getCustomers($stores)
{
echo mysql_num_rows($stores); //Outputs 6
while ($row = mysql_fetch_array($stores)) {
echo "test "; // Outputs nothing
}
// Return some result
}
Run Code Online (Sandbox Code Playgroud) 我正在使用Wordpress开发网站,我想使用lates版本的jQuery.
为了确保我使用lates版本,我从Binary Bonsai的例子中找到了这段代码.
我看到的是,他实际上是在Google API上链接到jQuery.
所以我的问题是,什么是更好的.
要链接到外部页面上的jQuery吗?
http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js
或者在本地使用jquery文件?
wp_enqueue_script('jquery', '/js/jquery-1.4.2.min.js');
UPDATE
感谢Colin,答案实际上就在这里:
为什么我要将Google的CDN用于jQuery?
但是,如果你没有Google像我这样的搜索词,我会复制John Gietzen的答案
它增加了可用的并行性.
(大多数浏览器一次只能从任何给定的站点下载3或4个文件)
它增加了缓存命中的可能性.
(随着越来越多的网站遵循这种做法,更多用户已准备好该文件.)
它确保有效载荷尽可能小.
(谷歌可以预先压缩文件,使下载时间非常短.)
它减少了服务器使用的带宽量.
(谷歌基本上提供免费带宽.)
它确保用户获得地理上接近的响应.
(谷歌在世界各地都有服务器,进一步减少了延迟.)
我需要返回动态加载的内容.我认为这是实现它的方法,但该函数返回空白.为了设置htmlCode从中检索的html代码,我需要做什么jQuery.ajax?
// Get directory listing
function getHTML(instance, current_path, dir) {
var htmlCode = '';
jQuery.ajax({
type: "POST",
url: "../wp-content/plugins/wp-filebrowser/jquery.php",
dataType: 'html',
data: {instance: instance, current_path: current_path, dir: dir},
success: function(html){
htmlCode = html;
},
error: function(e) {
htmlCode = '[Error] ' + e;
}
});
return htmlCode;
}
Run Code Online (Sandbox Code Playgroud) 我正在使用以下函数来检索日期和时间:
function formatEventTime($time, $type, $locale = 'nb_NO') {
setlocale(LC_TIME, $locale);
switch($type) {
case 'date' : $format = '%d.%m'; break;
case 'dm' : $format = '%d. %B'; break;
case 'time' : $format = '%H:%M'; break;
case 'dmy' : $format = '%d.%m.%Y'; break;
}
return strftime($format, strtotime($time));
}
Run Code Online (Sandbox Code Playgroud)
哇$time = 2010-12-03 10:00:00.问题是我的日子和月份仍然是英文.我如何将其更改为例如挪威语?
更新
这适用于我的服务器,但不适用于我的语言环境机器.
我有一个带有以下CSS的div:
#feedback {
min-height: 24px;
line-height: 24px;
margin-bottom: 10px;
display: none;
}
Run Code Online (Sandbox Code Playgroud)
然后我使用添加一些内容jQuery.
jQuery('.feedback_text').html(feedback.message);
jQuery('.feedback_icon').addClass(feedback.type);
jQuery('#feedback').fadeIn('normal', function() {
jQuery(this).height('100%');
});
Run Code Online (Sandbox Code Playgroud)
问题是,当我有多行文本时,DIV不会扩展.
我尝试过使用$('.feedback_text').height(),但它只给我CSS(24px)中指定的高度,而不是动态内容添加后的高度.
有人建议吗?
我正在尝试在页面上设置未知数量的plupload实例.我需要动态添加更多实例并删除和重置其中的一些实例.我有一般的想法,但没有任何作用.
我的一个尝试是在jsfiddle.
谢谢你的帮助.
码:
var uploaders = new Array();
initUploaders = function(uploaders) {
console.log("initUploaders()");
$(".gallery").each(function() {
var el = $(this);
var button = el.attr("id") + "_uploader";
console.log("Init uploader id:" + el.attr("id"));
var uploader = new plupload.Uploader({
runtimes: 'gears,html5,flash,silverlight,browserplus',
browse_button: button,
max_file_size: '10mb',
url: 'ModuleGallery/Upload/',
flash_swf_url: 'http://static.srv42.net/plupload/js/plupload.flash.swf',
silverlight_xap_url: 'http://static.srv42.net/plupload/js/plupload.silverlight.xap',
filters: [
{
title: "Image files",
extensions: "jpg,gif,png"}
]
});
uploader.bind('FilesAdded', function(up, files) {
uploader.start();
});
uploader.init();
galleryUploaders.push(uploader);
};
initUploaders(uploaders);
Run Code Online (Sandbox Code Playgroud) 我正在做一些计算,最后我65.0还是43.5.
我需要在这个数字上加零,以便我的数字比较有效:
$this->sub_total == $order_sub_total
我已经使用number_format()进行了测试:
$total = number_format($total, 2, '.');
Run Code Online (Sandbox Code Playgroud)
但这给了我一些消息: Wrong parameter count for number_format()
我很想做:
$total = $total.'0';
Run Code Online (Sandbox Code Playgroud)
但我认为这个数字是个坏主意35.43.
那么如何为我的号码添加额外的小数?
我正在使用结构化的JavaScript代码,它在我的计算机上工作正常.但是当我将它添加到jsFiddle时,它会给我以下错误:
SyntaxError: Unexpected token :
Run Code Online (Sandbox Code Playgroud)
我的代码看起来像这样:
var StentGallery = {
gallery: null,
init : function(){
this.gallery = jQuery('#gallery-list-ui');
this.resizeImage();
}
}
(...)
}
Run Code Online (Sandbox Code Playgroud)
有谁知道为什么这不适用于jsFiddle?
看看我的小提琴:https://jsfiddle.net/smyhbckx/
我需要将jQuery.click仅应用于第一级项目.我怎么做?
这是我的清单:
<ul id="adminMenu">
<li id="A">
<h3><a href="">Item 1</a></h3>
</li>
<li id="B">
<h3>Item 2</h3>
<ul style="display: block;">
<li id="a1"> Sub Item 1 </li>
<li id="a2"> Sub Item 2 </li>
<li id="a3"> Sub Item 3 </li>
</ul>
</li>
<li id="C">
<h3>Item 3</h3>
<ul style="display: none;">
<li> Sub Item 4 </li>
<li> Sub Item 5 </li>
</ul>
</li>
</ul>
Run Code Online (Sandbox Code Playgroud)
这是jQuery
jQuery('#adminMenu > li').click(function(){
alert('test');
});
Run Code Online (Sandbox Code Playgroud)
UPDATE
警报应该不是当我点击子菜单项开火,只有当我点击列表项A,B或C.
解决方案1
这是基于Marcels建议的工作代码.
jQuery('#adminMenu > li > h3').click(function(e) {
var activeUL = jQuery("#adminMenu > …Run Code Online (Sandbox Code Playgroud)