Tag Archive for list

List upcoming Events in Sidebar via PHP Code Widget

<?php $today = date ('Y-m-d'); ?>
<?php query_posts('cat=6&showposts=5&meta_key=event_date&meta_compare=>=&meta_value='.$today.'&orderby=meta_value&order=ASC'); ?>
<?php if ( have_posts() ) : ?>
  <ul>
  <?php while ( have_posts() ) : the_post(); ?>
   	<li class="cat-post-item"><a class="post-title" title="Permalink to <?php the_title() ?>" rel="bookmark" href="<?php the_permalink() ?>"><?php the_title() ?></a></li>   
  <?php endwhile; ?>
  </ul>
<?php endif; wp_reset_query(); ?>

source

Javascript count list items

<script type="text/javascript">

function count(){
var ul = document.getElementById('ulid');
var i=0, c =0;
while(ul.getElementsByTagName('li')[i++]) c++;
alert(c);
}

</script>


<input type="button" onclick="count()";>
<ul id="ulid">
<li>list 1</li>
<li>list 2</li>
<li>list 3</li>
<li>list 4</li>
<li>list 5</li>
</ul>

source

Sharepoint Ajax List Data populater Example

function btnSubmitEntry_OnClick() {
   $('#contentLoading').show(); 
   var ourProperty = EscapeHtmlString($('#selProperty :selected').text());
   var ourAffectedUrl = EscapeHtmlString($('#selUrl :selected').text());
   var ourStagingUrl;
   
  if (ourAffectedUrl.indexOf('/') == 0) {
   		if (ourProperty.indexOf('MS.com') > -1) ourStagingUrl = "<a href="http://wwwstaging"" >http://wwwstaging"</a> + ourAffectedUrl;
   		else if (ourProperty.indexOf('<a href="http://')" >http://')</a> > -1) ourStagingUrl = "<a href="http://standards"" >http://standards"</a> + ourAffectedUrl;
   		else ourStagingUrl ="n/a";
   		}
   else if ((ourAffectedUrl == "new page") || (ourProperty == "talkstandards.com")) ourStagingUrl ="to be determined" ;
   else ourStagingUrl ="n/a"  ;
   
   var updateString = "<Batch OnError="Continue">"; 
   updateString += "<Method ID="1" Cmd="New">"; 
   updateString += "<Field Name="ID">1</Field>"; 
   //updateString += "<Field Name="Title">" + EscapeHtmlString($("#txtTitle").val()) + "</Field>";
   updateString += "<Field Name="Title">Bug or Change Request </Field>"; 
   updateString += "<Field Name="Property">" + ourProperty + "</Field>"; 
   updateString += "<Field Name="Property_x0020_Owner">" + getPropertyOwner($('#selProperty :selected').text()) + "</Field>"; 
   updateString += "<Field Name="URL_x0020_Affected">" + ourAffectedUrl + "</Field>"; 
   updateString += "<Field Name="The_x0020_Requester">" + EscapeHtmlString($("#txtAuthor").val()) + "</Field>";
   updateString += "<Field Name="staging_x0020_url">" + ourStagingUrl + "</Field>";
   updateString += "<Field Name="Description">" + EscapeHtmlString($("#txtDescript").val()) + "</Field>";
   updateString += "<Field Name="Priority_x0020_Level">" + EscapeHtmlString($('#selPriority :selected').text()) + "</Field>";
   updateString += "<Field Name="Type_x0020_of_x0020_Request">" + EscapeHtmlString($('#selType :selected').text()) + "</Field>";
   updateString += "<Field Name="Go_x0020_Live_x0020_Date">" + EscapeHtmlString($("#txtGoLiveDate").val()) + "</Field>";
   updateString += "<Field Name="Go_x0020_Live_x0020_Time">" + EscapeHtmlString($("#txtGoLiveTime").val()) + "</Field>";
   updateString += "<Field Name="PageSection">" + EscapeHtmlString($("#txtSection").val()) + "</Field>"; 
   


    
 
   updateString += "</Method>"; 
   updateString += "</Batch>";
   try { 
   UpdateListItems("Change Requests", updateString, callback_Submit); }
   catch (err) {
   
   alert(err.message);
   
   }
   }	
   

function callback_Submit(respObj, status) {
   var soapError = SoapErrorCheck(respObj); 
   if (soapError.length == 0) {
      if (respObj.xml.length > 0) {
      var rows = $("z:row", respObj);
      requestID = trim($(rows[0]).attr("ows_ID"))
      
      var editUrl  = $("a#attachLink").attr("href") + "?ID=" + requestID;
      var attachmentUrl = $("a#custom-popup").attr("href") + "?ID=" + requestID; 
      
       $("a#attachLink").attr("href", editUrl );
      
      $("a#custom-popup").attr("href", attachmentUrl );
      
         $('#submittalConfirmation').show(); 
         $('#requestForm').hide(); 
         $('#contentLoading').hide(); 
         }
      else {
         alert("Error updating request list. Try again and if the error continues please contact your administrator."); 
         }
      }
   else {
      alert("Error submitting your request: 
" + soapError); 
      }
   }

source

PHP Country List

array(
	'AD' => 'Andorra',
	'AE' => 'United Arab Emirates',
	'AF' => 'Afghanistan',
	'AG' => 'Antigua and Barbuda',
	'AI' => 'Anguilla',
	'AL' => 'Albania',
	'AM' => 'Armenia',
	'AN' => 'Netherlands Antilles',
	'AO' => 'Angola',
	'AQ' => 'Antarctica',
	'AR' => 'Argentina',
	'AS' => 'American Samoa',
	'AT' => 'Austria',
	'AU' => 'Australia',
	'AW' => 'Aruba',
	'AZ' => 'Azerbaijan',
	'BA' => 'Bosnia and Herzegovina',
	'BB' => 'Barbados',
	'BD' => 'Bangladesh',
	'BE' => 'Belgium',
	'BF' => 'Burkina Faso',
	'BG' => 'Bulgaria',
	'BH' => 'Bahrain',
	'BI' => 'Burundi',
	'BJ' => 'Benin',
	'BM' => 'Bermuda',
	'BN' => 'Brunei Darrussalam',
	'BO' => 'Bolivia',
	'BR' => 'Brazil',
	'BS' => 'Bahamas',
	'BT' => 'Bhutan',
	'BV' => 'Bouvet Island',
	'BW' => 'Botswana',
	'BY' => 'Belarus',
	'BZ' => 'Belize',
	'CA' => 'Canada',
	'CC' => 'Cocos (keeling) Islands',
	'CD' => 'Congo, Democratic PeopleÕs Republic',
	'CF' => 'Central African Republic',
	'CG' => 'Congo, Republic of',
	'CH' => 'Switzerland',
	'CI' => 'Cote dÕIvoire',
	'CK' => 'Cook Islands',
	'CL' => 'Chile',
	'CM' => 'Cameroon',
	'CN' => 'China',
	'CO' => 'Colombia',
	'CR' => 'Costa Rica',
	'CS' => 'Serbia and Montenegro',
	'CU' => 'Cuba',
	'CV' => 'Cap Verde',
	'CS' => 'Christmas Island',
	'CY' => 'Cyprus Island',
	'CZ' => 'Czech Republic',
	'DE' => 'Germany',
	'DJ' => 'Djibouti',
	'DK' => 'Denmark',
	'DM' => 'Dominica',
	'DO' => 'Dominican Republic',
	'DZ' => 'Algeria',
	'EC' => 'Ecuador',
	'EE' => 'Estonia',
	'EG' => 'Egypt',
	'EH' => 'Western Sahara',
	'ER' => 'Eritrea',
	'ES' => 'Spain',
	'ET' => 'Ethiopia',
	'FI' => 'Finland',
	'FJ' => 'Fiji',
	'FK' => 'Falkland Islands (Malvina)',
	'FM' => 'Micronesia, Federal State of',
	'FO' => 'Faroe Islands',
	'FR' => 'France',
	'GA' => 'Gabon',
	'GB' => 'United Kingdom (GB)',
	'GD' => 'Grenada',
	'GE' => 'Georgia',
	'GF' => 'French Guiana',
	'GG' => 'Guernsey',
	'GH' => 'Ghana',
	'GI' => 'Gibraltar',
	'GL' => 'Greenland',
	'GM' => 'Gambia',
	'GN' => 'Guinea',
	'GP' => 'Guadeloupe',
	'GQ' => 'Equatorial Guinea',
	'GR' => 'Greece',
	'GS' => 'South Georgia',
	'GT' => 'Guatemala',
	'GU' => 'Guam',
	'GW' => 'Guinea-Bissau',
	'GY' => 'Guyana',
	'HK' => 'Hong Kong',
	'HM' => 'Heard and McDonald Islands',
	'HN' => 'Honduras',
	'HR' => 'Croatia/Hrvatska',
	'HT' => 'Haiti',
	'HU' => 'Hungary',
	'ID' => 'Indonesia',
	'IE' => 'Ireland',
	'IL' => 'Israel',
	'IM' => 'Isle of Man',
	'IN' => 'India',
	'IO' => 'British Indian Ocean Territory',
	'IQ' => 'Iraq',
	'IR' => 'Iran (Islamic Republic of)',
	'IS' => 'Iceland',
	'IT' => 'Italy',
	'JE' => 'Jersey',
	'JM' => 'Jamaica',
	'JO' => 'Jordan',
	'JP' => 'Japan',
	'KE' => 'Kenya',
	'KG' => 'Kyrgyzstan',
	'KH' => 'Cambodia',
	'KI' => 'Kiribati',
	'KM' => 'Comoros',
	'KN' => 'Saint Kitts and Nevis',
	'KP' => 'Korea, Democratic PeopleÕs Republic',
	'KR' => 'Korea, Republic of',
	'KW' => 'Kuwait',
	'KY' => 'Cayman Islands',
	'KZ' => 'Kazakhstan',
	'LA' => 'Lao PeopleÕs Democratic Republic',
	'LB' => 'Lebanon',
	'LC' => 'Saint Lucia',
	'LI' => 'Liechtenstein',
	'LK' => 'Sri Lanka',
	'LR' => 'Liberia',
	'LS' => 'Lesotho',
	'LT' => 'Lithuania',
	'LU' => 'Luxembourgh',
	'LV' => 'Latvia',
	'LY' => 'Libyan Arab Jamahiriya',
	'MA' => 'Morocco',
	'MC' => 'Monaco',
	'MD' => 'Moldova, Republic of',
	'MG' => 'Madagascar',
	'MH' => 'Marshall Islands',
	'MK' => 'Macedonia',
	'ML' => 'Mali',
	'MM' => 'Myanmar',
	'MN' => 'Mongolia',
	'MO' => 'Macau',
	'MP' => 'Northern Mariana Islands',
	'MQ' => 'Martinique',
	'MR' => 'Mauritania',
	'MS' => 'Montserrat',
	'MT' => 'Malta',
	'MU' => 'Mauritius',
	'Mv' => 'Maldives',
	'MW' => 'malawi',
	'MX' => 'Mexico',
	'MY' => 'Malaysia',
	'MZ' => 'Mozambique',
	'NA' => 'Namibia',
	'NC' => 'New Caledonia',
	'NE' => 'Niger',
	'NF' => 'Norfolk Island',
	'NG' => 'Nigeria',
	'NI' => 'Nicaragua',
	'NL' => 'Netherlands',
	'NO' => 'Norway',
	'NP' => 'Nepal',
	'NR' => 'Nauru',
	'NU' => 'Niue',
	'NZ' => 'New Zealand',
	'OM' => 'Oman',
	'PA' => 'Panama',
	'PE' => 'Peru',
	'PF' => 'French Polynesia',
	'PG' => 'papua New Guinea',
	'PH' => 'Phillipines',
	'PK' => 'Pakistan',
	'PL' => 'Poland',
	'PM' => 'St. Pierre and Miquelon',
	'PN' => 'Pitcairn Island',
	'PR' => 'Puerto Rico',
	'PS' => 'Palestinian Territories',
	'PT' => 'Portugal',
	'PW' => 'Palau',
	'PY' => 'Paraguay',
	'QA' => 'Qatar',
	'RE' => 'Reunion Island',
	'RO' => 'Romania',
	'RU' => 'Russian Federation',
	'RW' => 'Rwanda',
	'SA' => 'Saudi Arabia',
	'SB' => 'Solomon Islands',
	'SC' => 'Seychelles',
	'SD' => 'Sudan',
	'SE' => 'Sweden',
	'SG' => 'Singapore',
	'SH' => 'St. Helena',
	'SI' => 'Slovenia',
	'SJ' => 'Svalbard and Jan Mayen Islands',
	'SK' => 'Slovak Republic',
	'SL' => 'Sierra Leone',
	'SM' => 'San Marino',
	'SN' => 'Senegal',
	'SO' => 'Somalia',
	'SR' => 'Suriname',
	'ST' => 'Sao Tome and Principe',
	'SV' => 'El Salvador',
	'SY' => 'Syrian Arab Republic',
	'SZ' => 'Swaziland',
	'TC' => 'Turks and Caicos Islands',
	'TD' => 'Chad',
	'TF' => 'French Southern Territories',
	'TG' => 'Togo',
	'TH' => 'Thailand',
	'TJ' => 'Tajikistan',
	'TK' => 'Tokelau',
	'TM' => 'Turkmenistan',
	'TN' => 'Tunisia',
	'TO' => 'Tonga',
	'TP' => 'East Timor',
	'TR' => 'Turkey',
	'TT' => 'Trinidad and Tobago',
	'TV' => 'Tuvalu',
	'TW' => 'Taiwan',
	'TZ' => 'Tanzania',
	'UA' => 'Ukraine',
	'UG' => 'Uganda',
	'UM' => 'US Minor Outlying Islands',
	'US' => 'United States',
	'UY' => 'Uruguay',
	'UZ' => 'Uzbekistan',
	'VA' => 'Holy See (City Vatican State)',
	'VC' => 'Saint Vincent and the Grenadines',
	'VE' => 'Venezuela',
	'VG' => 'Virgin Islands (British)',
	'VI' => 'Virgin Islands (USA)',
	'VN' => 'Vietnam',
	'VU' => 'Vanuatu',
	'WF' => 'Wallis and Futuna Islands',
	'WS' => 'Western Samoa',
	'YE' => 'Yemen',
	'YT' => 'Mayotte',
	'YU' => 'Yugoslavia',
	'ZA' => 'South Africa',
	'ZM' => 'Zambia',
	'ZW' => 'Zimbabwe'
);

source

CSS Comma Separated List

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "<a href="http://www.w3.org/TR/html4/loose.dtd">" >http://www.w3.org/TR/html4/loose.dtd"></a>
<html>
 <head>
  <title>Comma separated list</title>
  <style>
#tags ul li{
  display:block;
  float:left;
  _display:inline;
  _float:none;
 }
#tags ul li::after{
  content:", ";
  white-space:pre;
 }
#tags ul li:first-child::before{
  content:"";
 }
#tags ul li:last-child::before{
  content:"& ";
  white-space:pre;
 }
 #tags ul li:last-child::after{
  content:"";
 }
#tags ul + *{
  clear:left;
 }
  </style>
 </head>
 <body>
  <div id="tags">
   <ul>
    <li>t-shirt (1)</li>
    <li>design (1)</li>
    <li>etiquette (1)</li>
   </ul>
  </div>
 </body>
</html>

source

CSS listimage

Example

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "<a href="http://www.w3.org/TR/html4/strict.dtd">" >http://www.w3.org/TR/html4/strict.dtd"></a>
<html>
 <head>
  <meta http-equiv="Content-Type" content="text/html; charset=windows-1251">
  <title>list-style-image</title>
  <style type="text/css">
   UL {
    list-style-image: url('images/book.gif');
   }
  </style>
 </head> 
 <body> 
 
  <ul>
   <li>Lorem ipsum dolor sit amet</li>
   <li>Consectetuer adipiscing elit</li>
   <li>Sed diem nonummy nibh euismod</li>
   <li>Tincidunt ut lacreet dolore magna aliguam erat volutpat. Ut wisis 
   enim ad minim veniam, quis nostrud exerci tution ullamcorper suscipit lobortis 
   nisl ut aliquip ex ea commodo consequat.</li>
  </ul>
 
 </body>
</html>

source

grouper des choix dans une liste déroulant (select, option et optgroup )

<select name="produits">
	  <optgroup label="Viandes">
	  <option selected="selected">Boeuf</option>
	  <option>Porc</option>
	  <option>Poulet</option>
	  </optgroup>
	  <optgroup label="Légumes">
	  <option>Salade</option>
	  <option>Carotte</option>
	  <option>Bétrave</option>
	  <option>Chou</option>
	  </optgroup>
	</select>

source

Howto list all the file extension types in an SVN log dump

svn log -v > myrepo.log

perl -ne 'print qq{$1
} if m{^s+.*(.[^.s]w+)$}' myrepo.log | sort | uniq -c | sort -r

source

Verify if content of 2 lists/arrays are eaqual

var listsEqual = function(list1, list2){
    var differences = 0;
    // check if all elements from first list exists in the second
    for(var i=0; i<list1.length;i++){   
        var exists = false;
        for(var j=0; j<list2.length; j++){
            if(list1[i] == list2[j]){
                exists = true;
                break;
            }
        }
        if(!exists){
            differences++;
            break;
        }
    }
    // and vice versa
    if(differences == 0){
        for(var i=0; i<list2.length;i++){
            var exists = false;
            for(var j=0; j<list1.length; j++){
                if(list2[i] == list1[j]){
                    exists = true;
                    break;
                }
            }
            if(!exists){
                differences++;
                break;
            }
        }
    }
    return differences == 0;
}

source

Quick directory list in PHP

// open this directory 
$myDirectory = opendir(".");

// get each entry
while($entryName = readdir($myDirectory)) {
	$dirArray[] = $entryName;
}

// close directory
closedir($myDirectory);

//	count elements in array
$indexCount	= count($dirArray);
Print ("$indexCount files<br>
");

// sort 'em
sort($dirArray);

// print 'em
print("<TABLE border=1 cellpadding=5 cellspacing=0 class=whitelinks>
");
print("<TR><TH>Filename</TH><th>Filetype</th><th>Filesize</th></TR>
");
// loop through the array of files and print them all
for($index=0; $index < $indexCount; $index++) {
        if (substr("$dirArray[$index]", 0, 1) != "."){ // don't list hidden files
		print("<TR><TD><a href="$dirArray[$index]">$dirArray[$index]</a></td>");
		print("<td>");
		print(filetype($dirArray[$index]));
		print("</td>");
		print("<td>");
		print(filesize($dirArray[$index]));
		print("</td>");
		print("</TR>
");
	}
}
print("</TABLE>
");

source