Question on javascript

Question on javascript

There will be two combo box in HTML form.If selecting in one combo box(ex:child id=1),the corresponding one to one matched value(ex:Child name=ashish) get selected automatically in another combo box.How to do this using JavaScript??? or any other way in web application???

View Answers

November 17, 2010 at 1:13 PM

Hello Friend,

In javascript, you can use the following code:

<html>
<h2>ComboBox</h2>
<script language="javascript">
var arr = new Array();
arr[0] = new Array("-select-");
arr[1] = new Array("A");
arr[2] = new Array("B");
arr[3] = new Array("C");
arr[4] = new Array("D");

function change(combo1){
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">1</option>
    <option value="2">2</option>
    <option value="3">3</option>
    <option value="4">4</option>
    </option>

</select><br />
<select name="combo2">
</select></form>
</html>

Thanks









Related Tutorials/Questions & Answers:
Question on javascript
Question on javascript  There will be two combo box in HTML form.If... to do this using JavaScript??? or any other way in web application???   Hello Friend, In javascript, you can use the following code:ADS_TO_REPLACE_1
Question on javascript
Question on javascript  This is not exactly what i wanted....If i enter in 2nd combobox as name of child then it should show child id in 1st combobox automatically and vice versa
Advertisements
Javascript Question about converting Celcius to Fahrenheit
Javascript Question about converting Celcius to Fahrenheit  How... to put var celsius and Fahrenheit after opening javascript? Do I have to prompt... To Farenheit</title> <script type="text/javascript"> //function temp
question
question   sir plz tell me what should i give in title box. just i want java program for the question typed in this area
question
question   sir plz tell me what should i give in title box. just i want java program for the question typed in this area
JavaScript
JavaScript  clone JavaScript
Question
Question   When there is an exception in my program how java runtime system handles
question
question  i used the following code to disable browser back page javascript:window.history.forward(1); but not worked .please give the correct code to disable back page using jsp or javascript
question
question  dear sir/madam my question is how to compare two text format in java..we are java beginners..so we need the complete source code for above mentioned question...we have to compare each and every word
question
question  i need a simple javascript or jsp code to send message from one mail to another mail
question
question  i need a simple javascript or jsp code to send message from one mail to another mail
question
question  how to display the uploaded video file size in database using java or javascript
question
question  Dear sir i had some typing mistake at previous question so its my humble request to let me know the steps to start the tomcat6 under the tomcat directory
question
question  how to list images from a file and how to display that images as four different images in each row using jsp / javascript
question
question  how to loop table rows in javascript ,jsp ,i want to list four images in each rows from a file
javascript
javascript  how to create random question using javascript?   <html> <script> function displayQuestions...="button" value="Question" onclick="displayQuestions();"> <label id="lab">
javascript
javascript  javascript code to dynamically add table on button click.../javascript/javascriptexamples/javascript-add-row-dynamically.shtml http://www.roseindia.net/javascript/javascript-add-row-to-table.shtml http://www.roseindia.net
Javascript
Javascript  How validations are done using javascript ,with example? and interview questions on javASCRIPT
JavaScript
should use JavaScript? Thanks   Hi, JavaScript is scripting language that runs on browser. You have to embed JavaScript in HTML page. Please see JavaScript tutorial. Thanks
JavaScript
JavaScript  how to get full path of a file type in javascript
javascript
javascript  Hi deepak, how to write form validation on javascript
javascript
javascript  write a program to display implement about browsers using javascript
javaScript
javaScript  How to open a browser window that cannot be resized? (HTML + Javascript
javascript
javascript  i have just learned javascript... can you tell me what kind of applications can be made by javascript?? thank you
question
question  Gud morning sir, I have asked u some question regarding jsp in saturaday for that i didnot find any answere in which u send me the some of the links.U have asked me the specify some details. There is a entity name
Question?
Question?  My question is how to: Add a menu bar to the program with a File menu. In the File menu, add a submenu (JMenuItem) called About. When the user clicks on the About menu item, display a JOptionPane message dialog
javascript
javascript  how to set the request or session attribute in javascript head part of jsp page
javascript
javascript  Hi sir, This is sinduri, i want to learn javascript, so plz can u help me.how to learn
javascript
javascript  hi sir, if i want to learn javascript. what concepts i want to know
JAVASCRIPT
JAVASCRIPT  I have one textbox and I want to validate that it must start with number(1-0). can anyone tell me a javascript for that ? thanks in advance
Javascript
Javascript   Javascript to check Numeric entry in checkbox.....   Hi Please find the following code for numeric entry validation in javascript function validateBox(){ var data=document.myForm.someText.value
javascript
javascript  hi, I was actually working on to calculate the number of days between two dates of yyyy-mm-dd format using javascript, and when i click on button then number of days should be display in textbox
javaScript
javaScript  . Print a table like below in JAVASCRIPT 5 x 1 = 5 5 x 2 = 10 ΓΆβ?¬Β¦ΓΆβ?¬Β¦ΓΆβ?¬Β¦. 5 x 20 = 100
javascript
javascript  passing javascript values to jsp   Hi Friend, Try the following code:ADS_TO_REPLACE_1 form.jsp: <html> <script>... Javascript value In JSP"> <% String st=request.getParameter("msg"); if(st
Javascript
this format xxx-xxx-xxxx, i want the code in javascript. as a function.   Javascript Phone Number Validation <html> <script> function..." method="post" onsubmit="javascript:return validate();"> Phone Number:<
Javascript
Javascript  Dear Sir, Thank You a lot for your continuos support.Again i am in need of your help. What is the javascript code to disable a link,once... javascript or css Please help me.Urgent Regards Debasis   Hello Friend
Javascript
Javascript  <html> <head> <script type="text/javascript"> function validateForm() { var sname=document.getElementById('spocname'); var scontact=document.getElementById('spoccontact'); if(sname.value.length
javascript
javascript
javascript
javascript  Hi deepak, sample example on javascript form validation   <html> <script> function checkName(text) { if(isNaN(text)){ return 1; } else{ alert("Please enter a valid name. The only charachters
What is JavaScript Variables ?
What is JavaScript Variables ?  Hi, My question is that What is Variable in JavaScript Programming Language. How to declare variables in JavaScript Program. Thanks, (adsbygoogle = window.adsbygoogle || []).push
What is javascript Arrays?
What is javascript Arrays?   Hi, I am learner of JavaScript. My question is that What is JavaScript Arrays ? How to Define the JavaScript arrays in you program. Please give an example show that i will try my self. Thanks
Javascript & jsp
Javascript & jsp  Dear Sir, Thanks a ton for all your answers throughout.I asked this question long ago.This time i nedd it very urgent.I think...; Askquestions> Question and Answers Please help me.It is urgent this time
Javascript & jsp
Javascript & jsp  Dear Sir, Thanks a ton for all your answers throughout.I asked this question long ago.This time i nedd it very urgent.I think...; Askquestions> Question and Answers Please help me.It is urgent this time
Javascript & jsp
Javascript & jsp  Dear Sir, Thanks a ton for all your answers throughout.I asked this question long ago.This time i nedd it very urgent.I think it might be a short solution.How can i get the navigation link whilr traversing
JavaScript types
JavaScript types  What are JavaScript types
php,javascript,html
php,javascript,html  Hi, thank u for answered the previous question. one more question: when i register the student details, unique register number should be created and incresed automatically for every student based
Javascript code
Javascript code  Dear Sir, Thank you a lot for your support throughout the process. Here again i am in a doubt.Can you please clarify? I have...,then it redirects it to Confirm.jsp.My question is how to show the page navigation
Javascript code
Javascript code  Thank you a lot for your support throughout the process. Here again i am in a doubt.Can you please clarify? I have a page called... it to Confirm.jsp.My question is how to show the page navigation details
Javascript code
Javascript code  Dear Sir, Thank you a lot for your support throughout the process. Here again i am in a doubt.Can you please clarify? I have a page...,then it redirects it to Confirm.jsp.My question is how to show the page navigation details

Ads