How to populate two drop-downs in JQuery with to/from dates

If you ever need to populate two sets of drop-downs with the from and to hours, use the following script in your head section:

"text/javascript">
        $(document).ready(function () {
            var i = 0;

            for (var i = 0; i var ampm = i % 24 'AM' : 'PM';

                var hours = i % 12;
                if ((hours === 0) && (i!=0)) {
                    hours = 12;
                }
                var valueString = ("0" + hours.toString()).slice(-2) + " " + ampm;

                $('#ddlFromHour').append($('')
                        .attr('value', i)
                        .text(valueString));
                $('#ddlToHour').append($('')
                        .attr('value', i)
                        .text(valueString));
            }
            for (var i = 0; i var valueString = ("0" + i.toString()).slice(-2);

                $('#ddlFromMinute').append($('')
                        .attr('value', i)
                        .text(valueString));
                $('#ddlToMinute').append($('')
                        .attr('value', i)
                        .text(valueString));
            }
        });
    

Output will be two sets of drop-downs with “From and To Times”
Capture

Advertisements

Calling WCF Web-Service from behind a proxy server

If you ever have any issues bypassing a proxy server in order to call a webservice (WCF or SOAP), you can modify your web-config file to show the following:

<system.net>
<defaultProxy useDefaultCredentials=”true”>
<proxy proxyaddress=”http://AAA.BBB.CCC.DDD:PORTNO&#8221; usesystemdefault=”True” />
</defaultProxy>
</system.net>

or

The proxy settings are part of the binding configuration.

<configuration>
  <system.serviceModel>

    <bindings>
      <basicHttpBinding>
        <binding name="Binding1"
                 proxyAddress = "http://myProxy">
          <security mode="None" />
        </binding>
      </basicHttpBinding>
    </bindings>

  </system.serviceModel>

</configuration>