Skip to main content

Posts

Showing posts from September, 2012

JSON parsing in JAVA

JSON parsing in JAVA package jsonsample; import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; public class JsonSample { public static void main(String[] args) { String str = "{'status': 'ok','found': true," + "'header': {'queried_sn': 'T0650GW872832', 'mfpro_env': 'deere_staging', 'elapsed_seconds': 2.314,'timestamp': '2012-06-14 07:12:18'}," + "'machine': { 'mfpro_machine': {'updated_at': '2012-05-22T10:23:54-04:00','matches': 3,'hours': 6809,'id': 1140530,'features': " + "[{'key': 'pat','label': 'Power-Angle-Tilt','feature_key': 'cons_blades'}]}," + "'make': {'name': 'John Deere','id': 100,'pi': null}," + "

Dynamically adding content in Dropdown in Javascript

<html> <head> <script type="text/javascript"> function addOption(dropdown,text,value ) { var optn = document.createElement("OPTION"); optn.text = text; optn.value = value; dropdown.options.add(optn); } </script> </head> <select id="year" name="year" style="width: 70px" ></select> <script type="text/javascript"> var date = new Date(); var startYear = '2000' ; var currentYear = date.getFullYear(); do   {    addOption(document.getElementById("year"), currentYear, currentYear);    currentYear--;   } while (currentYear >= startYear); </script> </BODY> </html> *************Output*************

C# List Examples

C# List Examples 1. Adding values ~~~ Program that adds elements to List (C#) ~~~ using System.Collections.Generic; class Program {       static void Main()       {             List list = new List();             list.Add(2);             list.Add(3);             list.Add(5);             list.Add(7);       } } *********************************************************************************** 2. Adding objects. Using Add method ~~~ Program that uses Add method (C#) ~~~ using System.Collections.Generic; class Program {       static void Main()       {             // Add first four numbers to the List.             List primes = new List();             primes.Add(2);             primes.Add(3);             primes.Add(5);             primes.Add(7);       } } *********************************************************************************** 3. Adding objects -- Program that adds objects to List (C#) --- us