Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa JavaScriptQuestions problem in array if condtion
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


prince
problem in array if condtion
1 Answer(s)      2 years and 4 months ago
Posted in : JavaScript Questions


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


Advertisement
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...(System.in); int array[]=new int[5]; System.out.println("Enter Array Elements
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  array memory allocation is dynamic or static in java   Java Arrays have dynamic memory allocation
Array
Array  can we create an array of size 1 lakh in java programming
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  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
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  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
Advertisements
 

 

 

DMCA.com