problem in array if condtion

problem in array if condtion

sir i have prblem in js...i have array drop down list i.e like when i select country it will give the list of states of that country in second drop list and same as if i select state it will give city list of particular state....now i add a go button to it...when ever i press on it it should openrealted web pages...the script of go button is like this

function go() { var powerStation = document.getElementById('city').value;

if (cities['Alladurg']['Alladurg']=="Power station 1") 

//window.open('popup.html',"_self","directories=no, status=no, menubar=no, scrollbars=yes, resizable=no,width=600, height=280,top=200,left=200");
{ window.open('https://www.google.co.in/')}


 if (cities['Andole']['Mansanpalle']=="Power station 6") 


{ window.open('http://www.w3schools.com/')}

}

.......but the prblem is i am opening only one web page that too one related state..i want open so many related web page....when i press on go button....means

if i select country america it will get states of america in second list and if i select state it will get cites of that particular state...and then if i press go button it should open that america related page....

same as....like if i selcet another country state and city..if i press go button it should open another which is related to the country pls help throght that function code

View Answers

July 4, 2012 at 11:21 AM

Here is a javascript code of dependent dropdownlist. When you select country it will give the list of states of that country in second drop list. Similarly, you can create a city dropdownlist.

<html>
<h2>ComboBox</h2>
<script language="javascript">
var arr = new Array();
arr[0] = new Array("-select-");
arr[1] = new Array("Maharashtra","Karnataka","Kerela","Rajashthan");
arr[2] = new Array("Texas","New York","Florida","California");

function change(combo1)
{
document.getElementById("sel").style.visibility="visible";
var comboValue = combo1.value;
document.forms["form"].elements["combo2"].options.length=0;
for (var i=0;i<arr[comboValue].length;i++)
{
var option = document.createElement("option");
option.setAttribute('value',i+1);
option.innerHTML = arr[comboValue][i];
document.forms["form"].elements["combo2"].appendChild(option);
}
}

</script>
<form name="form" method="post">
<select name="combo1" onchange="change(this);">
<option value="0">-Select-</option>
<option value="1">India</option>
<option value="2">USA</option>
</option>

</select><br />
<select id="sel" name="combo2" style="visibility:hidden;">
</select>

</form>
</html>









Related Tutorials/Questions & Answers:
problem in array if condtion
problem in array if condtion  sir i have prblem in js...i have array... = new Array(); arr[0] = new Array("-select-"); arr[1] = new Array("Maharashtra","Karnataka","Kerela","Rajashthan"); arr[2] = new Array("Texas","New York","Florida
array problem
array problem  An integer array a has 19 elements. What is the value of the middle element after the following codes is executed? int i, j,n=19; for (i=0; i for(i=0, j=n-1; i<=j; i++, j--) a[(i+j)/1] -= (a[i]+a[j])/2
Advertisements
Problem in Array
Problem in Array  Hi, Can you help me with this problem? Run a program that check if the input string contains equal number of A's and B's. Hoping for your answer.Thank you.   Here is an example that check
Array /string based problem....
Array /string based problem....  thanx to help me.but again a problem... solve this problem also as soon as possible..... import java.util.*; public class... or char"); char[] array = new char[5]; for(int i=0;i<5;i++){ char ch
string array based problem
string array based problem  R/sir, firstly thanks... sorted value: 11 12 13 3 this is the problem here...... import java.util.*; public... string: "); String[] array = new String[5]; for(int i=0;i<5;i++){ array[i
java array problem
java array problem  suppose i have an array a[] at a[0] i have value 5,7 the thing is that i want to assign the value of array a[0]=5,7 to two variable let it be j,k that is j=5 and k=7 plz help regards
array and string based problem
array and string based problem  this program is accepting only..._srt(int array[],int n){ for (int j = 0; j < n; j++){ int i = j-1; int k = array[j]; while ((i>= 0) && (array[i] > k)){ array[i
array and string based problem
array and string based problem  this program is accepting only..._srt(int array[],int n){ for (int j = 0; j < n; j++){ int i = j-1; int k = array[j]; while ((i>= 0) && (array[i] > k)){ array[i
array and string based problem
array and string based problem  this program is accepting only..._srt(int array[],int n){ for (int j = 0; j < n; j++){ int i = j-1; int k = array[j]; while ((i>= 0) && (array[i] > k)){ array[i
Array problem - JSP-Servlet
Array problem  Respected Sir/Madam, I am having a pop up window in which the database values are available.. Its in the format of: One..... Bur my problem is that if the pop up window contains only 1 record
palindrome array problem
palindrome array problem  I'm having trouble figuring this assignment out. Can someone please help me? Generate (write the code) and save in an array Palidrome[250][5] all the 5 letter words using {a, b, c} Write the code
array problem java - Java Beginners
array problem java  PLS HELP ME NOW I NEED YOU RESPONSE IMMDEATLETLY HOPE ITS OK... 1.) Consider the method headings: void funcOne(int[] alpha..., respectively. another problem.,, 2.)Suppose list is an array of five
Facing Problem to insert Multiple Array values in database - JSP-Servlet
Facing Problem to insert Multiple Array values in database  Hai... facing the problem while inserting the data in database. iam using the MsAccess... Manoj   Hi friend, You Have Problem in Data Table and check
in_array
in_array  in_array in php
is _array()
is _array()  is_array() in php   Hi Friend, This function is of Boolean type.It checks whether a variable is an array or not. Here is an example: <?php $yes = array('Hello', 'World'); echo is_array($yes) ? 'Array
is _array()
is _array()  is _array()   Hi Friend, This function is of Boolean type.It checks whether a variable is an array or not. Here is an example: <?php $yes = array('Hello', 'World'); echo is_array($yes) ? 'Array
Array
Array  how can i use elements of an array in a circular form? that is if the searching of the element reach the last elements of the array, then it will start serching from the begining of the array
Array
Array  is it possible to define array like this..? int[] intArray = new int[] {4,5,6,7,8}; Explain...?   Yes, you can. Java Initialize Array
Array
Array  What if i will not declare the limit index of an array, how will I declare an array and store values with it using loop?   Hi Friend... Scanner(System.in); int array[]=new int[5]; System.out.println("Enter
array
array  write and test a function named mirror that is passed an array of n floats and returns a newly created array that contains those n floats... the array {10.1,11.2,8.3,7.5,22} into{22,7.5,8.3,11.2,10.1
array
array  write and test a function named mirror that is passed an array of n floats and returns a newly created array that contains those n floats... the array {10.1,11.2,8.3,7.5,22} into{22,7.5,8.3,11.2,10.1
array
array  write and test a function named mirror that is passed an array of n floats and returns a newly created array that contains those n floats... the array {10.1,11.2,8.3,7.5,22} into{22,7.5,8.3,11.2,10.1
Array
Array  How do i insert elements into an array up to a limit from...("Enter Range: "); int size=input.nextInt(); int array[]=new int[size]; System.out.println("Enter Array Elements: "); for(int i=0;i<
array
array  WAP in java to store 6 element in array P and 4 element in array Q. Produce the third arra y R containing all element from p & q
Array
Array  can we create an array of size 1 lakh in java programming
array
array  array memory allocation is dynamic or static in java   Java Arrays have dynamic memory allocation
array
array  create an array in which no element is duplicate. if duplicate then tell to user duplicate. duplicacy is tell to user during when he enter the element
array
array  create an array in which no element is duplicate. if duplicate then tell to user duplicate. duplicacy is tell to user during when he enter the element
array
array  take a 2d array and display all its elements in a matrix fome using only one for loop and ple explain the program in below
array
accepts a pointer to integer which represents an array of integer.After that this method prints the entire of the array numbers to the monitor. include using std::cout; using std::endl; void printArray(int *array, int count
array
array  How to store the results of mysql query in an array... qurey in array: "select distinct(EMPLID)from tblwork where EMPLID not in (select... store the result in array
array
array  wap to calculate reverse of 10 elements in an array?  ...(); } System.out.print("Array is: "); for(int i=0;i<arr.length;i...(); System.out.print("After reversing, Array is: "); for(int i=arr.length-1;i>=0
Array's
Array's  I have to finish an "order page". that checks 2 dropdown boxes and a set of radio buttons and put the results into a set of textboxes, 1 line at a time, then calculate a total. I know I need to create an array, but I'm
Array
Array  i having problem how to make algorithm for [a][5] [a][10] [b][15] [b][10] [c][5] [c][5] . . . . sum of [a] = 15 [b] = 25 [c] = 10
array
array  Hi i have array like {1,2,3,4,,5,5,6,6} then how can i... is an example that store some integers into an array and find the occurrence of each number from the array. import java.util.*; public class SearchNumberOccurrence
array
array  how to getting values and storing values in array by using datainputstream?   Hi Friend, Try the following code:ADS_TO_REPLACE_1...("Array Elements are: "); for(int i=0;i<arr.length;i
Array
reserved. Use a one-dimensional array of primitive type Boolean to represent the seating chart of the cinema theater. Initialize all the elements of the array... the corresponding elements of the array to true to indicate that the seat is no longer
PHP Push Array to Array
PHP Push Array to Array  array_push() function using array in PHP
Create Array ??
Create Array ??   Question in e-clips program: Part 1. Array... stores list of â??PhoneEntryâ?? objects. Use an array of size (MAXSIZE = 1000... directory problem defined above. Part 2. Linked List Implementation Create
Array sort
Array sort  Program that uses a function to sort an array of integers
array example
array example  giving input from outside for array example
java array
java array Two cells is a matrix will be called connected if they are adjacent...]. But it will not connected to cell a[1,1] For this problem, lets say, cells denoted by integer...], a[3,2], a[3,3] } elements with weight 6 Problem: Implement Java code which
array of string
array of string  Waht is the problem in this code? import java.util.Scanner; public class LastCheck { public static void main(String args[]){ int a; Scanner s= new Scanner(System.in); a=s.nextInt(); String ar[]=new
Array sorting - Java Beginners
"Arrays.sort(name)" but the problem is that my relationship with the "type" array...Array sorting   Hello All. I need to sort one array based on the arrangement of another array. I fetch two arrays from somewhere
problem in onlinetest...
problem in onlinetest...  hi, my code getting the problem is ,when user leave a question then the server puts error... pls help me
length in array
length in array  wat s length in array
Java array
Java array   How can one prove that the array is not null but empty
array ADT
array ADT  Write a program using array_ADT to retrieve a list of elements from a file
array ADT
array ADT  Write a program using array_ADT to retrieve a list of elements from a file
Array of structure
Array of structure  create employment details with necessary field using array of structure

Ads