小编Ste*_*ven的帖子

如何使用jQuery一次性禁用多个列表框?

我可以通过这样做禁用一个和一个:

jQuery('#ListBoxA').attr('disabled','true');
Run Code Online (Sandbox Code Playgroud)

但是如何将其应用于多个项目?这不起作用:

jQuery('#ListBoxA, #ListBoxB, #ListBoxC').attr('disabled','true');
Run Code Online (Sandbox Code Playgroud)

UPDATE

显示的标记不多....

<select id="ListBoxA" size="4" name="countrySelectBox">
<select id="ListBoxB" size="4" name="cityListBox">
<select id="ListBoxC" size="4" name="storeListBox" multiple="multiple">
Run Code Online (Sandbox Code Playgroud)

jquery listbox

3
推荐指数
1
解决办法
4981
查看次数

如何在<ItemTemplate>(.NET)中获得备用样式?

我在这个网站上使用EPiServer.不像asp:DataList,EPiServer:PAgeList没有AlternatingItemTemplate.

所以我需要创建一个计数器并在我的增加这个计数器<ItemTemplate>,然后使用模数返回很多css样式附加到文章/页面.

模数"代码" - 来自后面的代码:

 return index % 2 == 0 ? "styleA" : "styleB";
Run Code Online (Sandbox Code Playgroud)

但我不能在计数器上加一个计数器来增加它<ItemTemplate>.

任何建议非常感谢!

更新
这是我的EPiServer页面列表控制器:

 <EPiServer:PageList runat="server" id="pageList" SortDirection="Ascending" Count="4" OnDataBinding="pageList_OnDataBinding">
    <HeaderTemplate>
        <ul id="articleList1">
    </HeaderTemplate>

    <ItemTemplate>
            <li>
                   <h2><a href="<%# Eval("LinkURL") %>" title="<%# Eval("PageName") %>"><EPiServer:Property id="Property1" PropertyName="PageName" runat="server" /></a></h2>
                   <div class="articleImage">
                      <%# ArticleImage(Container.CurrentPage)%>                            
                   </div>
                   <div class="introText">
                      <%# IntroText(Container.CurrentPage)%> 
                   </div>
                   <div class="readMore floatRight"><a href="<%# Eval("LinkURL") %>" title="<%# Eval("PageName") %>">Les mer</a></div>
            </li>
    </ItemTemplate>

    <FooterTemplate>
        </ul>     
    </FooterTemplate>
 </EPiServer:PageList> 
Run Code Online (Sandbox Code Playgroud)

答案
我决定使用jQuery比使用.NET更简单.这不是我的首选解决方案,但它确实有效.我使用的代码是这样的:

if (jQuery("#articleList1").length …
Run Code Online (Sandbox Code Playgroud)

.net css repeater itemtemplate modulo

3
推荐指数
1
解决办法
1万
查看次数

为什么$ wpdb-> insert_id和mysql_insert_id()最后返回一个额外的'1'?

我需要检索上一个查询的AUTO_INCREMENT值的ID.

我的查询如下所示:

  $result = $wpdb->query( $wpdb->prepare( "
    INSERT INTO $table_name
    ( name, season, copyright, description, path )
    VALUES ( %s, %s, %s, %s, %s )", 
    $galleryData['name'], $galleryData['season'], $galleryData['copyright'], $galleryData['description'], $galleryData['path'] ) );

  // Let's output the last autogenerated ID.
  echo $wpdb->insert_id;

  // This returns the same result
  echo mysql_insert_id();
Run Code Online (Sandbox Code Playgroud)

查看我的数据库表,我看到行数从1到24(24行).但使用$wpdb->insert_idmysql_insert_id()返回241.

执行新插入将返回251,261,271等.为什么我最后加上额外的'1'?

更新
感谢Pekka(我最好坚持运行我欠他的啤酒数量的标签),我想通了.

在代码的下面我得到了这个:

  if(!$result)
    _e("[DB error] Ups. Something went wrong when trying to insert the event.");
  else
    echo true;
Run Code Online (Sandbox Code Playgroud)

这是最后一个声明(echo true)!

php wordpress

3
推荐指数
1
解决办法
9539
查看次数

如何"捕获"列表中的每个第7项?

我正在使用DirectoryIterator列出文件.在这种情况下,我的目录包含19个文件.

我需要创建一个包含7个文件的列表<div>.

我一定很累,因为我无法做这个简单的任务.

我的代码已更新,以反映以下建议:

$i = 0;
echo '<div class="first_div">';

foreach ($dir as $fileinfo) {
  if ($fileinfo->isFile()) {
    if(($i % 7 == 0) && ($i > 0) )
      echo '</div><div>';

    echo 'My file';
    $i++;
  }
}
echo '</div>';
Run Code Online (Sandbox Code Playgroud)

有任何帮助.

php

3
推荐指数
1
解决办法
340
查看次数

PHP函数将ø转换为&Aring ;?

谁能告诉我PHP函数转换ø&Aring;什么?

我存储特殊字符,如æ, ø, å, ö, ähtml编码字符.

我搜索谷歌和Stackoverflow,但无法弄清楚要搜索什么.
我以前管它,但不记得如何:(

以下不起作用:

$tmp = ('Øving, ære, blå');
$tmp2 = htmlspecialchars($tmp);
echo $tmp.' - '.$tmp2;
Run Code Online (Sandbox Code Playgroud)

输出是: Øving, ære, blå - Øving, ære, blå

我也尝试过htmlentities:

$tmp = ('Øving, ære, blå');
$tmp2 = htmlentities($tmp);
echo $tmp.' - '.$tmp2;
Run Code Online (Sandbox Code Playgroud)

这输出: Øving, ære, blå - Ã?ving, ære, blÃ¥

当我想要的时候
Øving, ære, blå - &Oslash;ving, &aelig;re, bl&aring;

php

3
推荐指数
1
解决办法
5423
查看次数

需要帮助Regex从字符串中提取邮政编码

我需要从字符串中提取邮政编码.字符串看起来像这样:

Sandviksveien 184, 1300 Sandvika
Run Code Online (Sandbox Code Playgroud)

如何使用正则表达式提取邮政编码?在上面的字符串中,邮政编码为1300.

我在路上尝试过这样的东西:

Regex pattern = new Regex(", [0..9]{4} ");
string str = "Sandviksveien 184, 1300 Sandvika";
string[] substring = pattern.Split(str);
lblMigrate.Text = substring[1].ToString();
Run Code Online (Sandbox Code Playgroud)

但这不起作用.

c# regex

2
推荐指数
1
解决办法
3419
查看次数

为什么我得到"map.set_center不是函数"?

这段代码一直有效,直到我昨晚更新.
代码在我的localhost上完美运行,但是我的测试服务器上出现错误.错误消息(来自Firebug)是"map.set_center is not a function".

那为什么这不再适用于我的服务器呢?

  function googleMapInit() 
  {    
    if (jQuery('#map_canvas').length > 0) {
      var currentLocation    = jQuery('#geomap_ddlCity :selected').text() + ', ' + jQuery('#geomap_ddlCountry :selected').text();
      var options   = {zoom: 14, mapTypeId: google.maps.MapTypeId.ROADMAP }
      var map       = new google.maps.Map(document.getElementById("map_canvas"), options);
      var geocoder  = new google.maps.Geocoder();

      //Center map for current selected city
      geocoder.geocode(    
      { 
        address: currentLocation}, function(results, status)
        {
            if (status == google.maps.GeocoderStatus.OK && results.length) {
                alert(results[0].geometry.location);
                map.set_center(results[0].geometry.location);
            } else 
            {
                var oslo = new google.maps.LatLng(59.9167, 10.75);
                map.set_center(oslo);
            } …
Run Code Online (Sandbox Code Playgroud)

javascript google-maps geocoding google-maps-api-3

2
推荐指数
1
解决办法
1284
查看次数

如何将内部div与外部div的底部对齐?

我需要将内部div与外部div的底部对齐.

我的代码看起来像这样:

<div class="myOuterDiv">
    <div class="div1 floatLeft"> Variable content here </div>
    <div class="div2 floatRight"> <img class="myButton" src="" /> </div>
</div>
Run Code Online (Sandbox Code Playgroud)

'div1'的内容可能会有所不同,因此外部div的高度会发生变化.如何确保我的按钮(div2)始终位于外部div的底部?

我更喜欢使用CSS,但如果不可能,我可以使用jQuery.

UPDATE

我选择以jQuery方式执行此操作,在此我遇到了一些问题.这一切都解决了,你可以在这里找到我的工作解决方案:如何使用jQuery计算元素跨浏览器的高度?

html css jquery

2
推荐指数
1
解决办法
7531
查看次数

如何 preg_replace 特殊字符,如“Prêt-à-porter”?

在这个论坛和网络上有很多关于这个问题的问题。\n但我不明白。

\n\n

这是我的代码:

\n\n
function updateGuideKeywords($dal)\n{\n    $pattern = "/[^a-zA-Z-\xc3\xaa\xc3\xa0\xc3\xa9]/";\n    $keywords = preg_replace($pattern, \'\', $_POST[\'keywords\']);\n    echo json_encode($keywords);\n}\n
Run Code Online (Sandbox Code Playgroud)\n\n

现在,输入是Pr\xc3\xaat-\xc3\xa0-porter,输出是"Pr\\u00eat-\\u00e0-porter"

\n\n

为什么我会得到 \'\\u00e\' ?

\n\n

我怎样才能改变我的模式以包含这些字符\xc3\xaa\xc3\xa0以及\xc3\xa9

\n\n

编辑
\nhumm...因为它看起来像unicode/字符问题,我可能会寻求我在本页上找到的解决方案找到的解决方案。

\n\n

在这里他们建议这样做:

\n\n
$chain="pr\xc3\xaat-\xc3\xa0-porter";\n\n$pattern = array("\'\xc3\xa9\'", "\'\xc3\xa8\'", "\'\xc3\xab\'", "\'\xc3\xaa\'", "\'\xc3\x89\'", "\'\xc3\x88\'", "\'\xc3\x8b\'", "\'\xc3\x8a\'", "\'\xc3\xa1\'", "\'\xc3\xa0\'", "\'\xc3\xa4\'", "\'\xc3\xa2\'", "\'\xc3\xa5\'", "\'\xc3\x81\'", "\'\xc3\x80\'", "\'\xc3\x84\'", "\'\xc3\x82\'", "\'\xc3\x85\'", "\'\xc3\xb3\'", "\'\xc3\xb2\'", "\'\xc3\xb6\'", "\'\xc3\xb4\'", "\'\xc3\x93\'", "\'\xc3\x92\'", "\'\xc3\x96\'", "\'\xc3\x94\'", "\'\xc3\xad\'", "\'\xc3\xac\'", "\'\xc3\xaf\'", "\'\xc3\xae\'", "\'\xc3\x8d\'", "\'\xc3\x8c\'", "\'\xc3\x8f\'", "\'\xc3\x8e\'", "\'\xc3\xba\'", "\'\xc3\xb9\'", …
Run Code Online (Sandbox Code Playgroud)

php preg-replace

2
推荐指数
1
解决办法
2万
查看次数

异步加载谷歌地图v3的问题

我目前用于加载Google地图脚本的解决方案是旧时尚方式.

<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=true"></script>
Run Code Online (Sandbox Code Playgroud)

但这需要很长时间,渲染内容会延迟.然后我查看了谷歌地图文档,并发现了如何异步加载Goole Map javascripts.

所以我在我已经使用的javascript中对此进行了测试.这只是我脚本的片段.

jQuery(document).ready(function() {
  googleMaploadScript();
  someFunction();
}

// Script for loading googlemap with callback to initialize Google map
function googleMaploadScript() {
  var script = document.createElement("script");
  script.type = "text/javascript";
  script.src = "http://maps.google.com/maps/api/js?sensor=true&callback=initGoogleMap";
  document.body.appendChild(script);
}

// Some function that calls populateGeoMap()
function someFunction() {
(...)
populateGeoMap(); 
}

// Script for populating google map with locations
function populateGeoMap() {
  // This is where I initialized google map each time I load the page using google …
Run Code Online (Sandbox Code Playgroud)

php jquery google-maps-api-3

2
推荐指数
1
解决办法
9425
查看次数