javascript error while selecting select option...

Hi developers,

I am new to javascript. Now i am developing Application form. In my form when i am selecting country in sleect box then automatically load states in states select box.

This is my code...

<%@ page contentType="text/html; charset=iso-8859-1" language="java" import="java.sql.*" errorPage="" %>

<!DOCTYPE html PUBLIC"-//W3C//DTD XHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />

<title>Untitled Document</title>

<script language="javascript">

function sele()

{

var con = document.frm.country.value;

var ap =new Array("Andhrapradesh","Tamilnadu","Karnataka","Kerala","Goa","Delhi");

ap.sort();

if(con =="1")

{

for(int k =0;k<ap.length;k++)

{

document.frm.state.options[k].text=ap[k];

}

}

}

></script>

</head>

<body>

<form action="regist.jsp" method="post" name="frm">

Country <select name="country" onchange="sele()">

<option>Choose</option>

<option value="1">India</option>

</select>

State <select name="state">

<option></option>

<option></option>

<option></option>

<option></option>

<option></option>

<option></option>

</select>

</form>

</body>

</html>

with Regards

sure...:)-

[2625 byte] By [sure_2912a] at [2007-11-26 21:23:59]
# 1

Hi developers,

I got solutions for this. I do one mistake.

This the solution:

<%@ page contentType="text/html; charset=iso-8859-1" language="java" import="java.sql.*" errorPage="" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />

<title>Untitled Document</title>

<script language="javascript">

function sele()

{

var con = document.frm.country.value;

var ap = new Array("Andhrapradesh","Tamilnadu","Karnataka","Kerala","Goa","Delhi");

ap.sort();

if(con == "1")

{

for(var a = 0;a<ap.length;a++)

{

document.frm.state.options[a].text=ap[a];

}

}

}

></script>

</head>

<body>

<form action="regist.jsp" method="post" name="frm">

Country <select name="country" onchange="sele()">

<option>Choose</option>

<option value="1">India</option>

</select>

State <select name="state">

<option></option>

<option></option>

<option></option>

<option></option>

<option></option>

<option></option>

</select>

</form>

</body>

</html>

with Regards

sure...:)-

sure_2912a at 2007-7-10 3:03:47 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...