Java is a set of computer software and specifications developed by Sun Microsystems, which was later acquired by the Oracle Corporation, that provides a system for developing application software and deploying it in a cross-platform computing environment. Java is used in a wide variety of computing platforms from embedded devices and mobile phones to enterprise servers and supercomputers.

Spring Logo

Spring Framework

The Spring Framework provides a comprehensive programming and configuration model for modern Java-based enterprise applications - on any kind of deployment platform. A key element of Spring is infrastructural support at the application level: Spring focuses on the "plumbing" of enterprise applications so that teams can focus on application-level business logic, without unnecessary ties to specific deployment environments.

Hibernate Logo

Hibernate Framework

Hibernate ORM is an object-relational mapping framework for the Java language. It provides a framework for mapping an object-oriented domain model to a relational database.

Sunday, July 15, 2012

Add Dropdown Country & State List Dynamically into HTML form by Javascript

In this post, we are going to see how to implement the dynamic dropdown with selected values.
<script lang="javascript">
var arr = new Array();
arr[0] = new Array("-Select District-");
arr[1] = new Array("Anantapur", "Chittoor", "Kadapa", "Kurnool");
arr[2] = new Array("Bellary", "Bangalore", "Mysore", "Udipi");
arr[3] = new Array("Madras", "Salem", "Coimbuttur");
function stateChange(State) {
var stateValue = State.value;
document.forms["myForm"].elements["District"].options.length = 0;
for (var i = 0; i < arr[stateValue].length; i++) {
var option = document.createElement("option");
option.setAttribute('value', i + 1);
option.innerHTML = arr[stateValue][i];
<h2>State and District Demo</h2>
<form name="myForm" method="post">
<select name="State" onchange="stateChange(this);">
<option value="0">-Select State-</option>
<option value="1">Andhra Pradesh</option>
<option value="2">Karnataka</option>
<option value="3">Tamil Nadu</option>
</select><br /> <select name="District">
<h1>Designed by Ranga Reddy.