Share on Google+Share on Google+

Rahul
Question on javascript
1 Answer(s)      6 years and 5 months ago
Posted in : JavaScript Questions

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???

Ads

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: <html> <
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 insert Question -
JAVASCRIPT insert Question  It is easy to transmit information from HOST program (in my case PHP program) to JAVASCRIPT insert. How may I reverse this, passing YES/NO information from a CONFIRM BOX back to the PHP program
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
Question
Question   When there is an exception in my program how java runtime system handles
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 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  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  i need a simple javascript or jsp code to send message from one mail to another mail
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  clone JavaScript
javascript
javascript  how to create random question using javascript?   <html> <script> function displayQuestions...="button" value="Question" onclick="displayQuestions();"> <label id="lab">
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  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
javaScript  How to open a browser window that cannot be resized? (HTML + Javascript
javascript
javascript  write a program to display implement about browsers using javascript
javascript
javascript  Hi deepak, how to write form validation on javascript
JavaScript
JavaScript  how to get full path of a file type in 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  i have just learned javascript... can you tell me what kind of applications can be made by javascript?? thank you
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  how to set the request or session attribute in javascript head part of jsp page
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
Tutorials   
Java Spring Hibernate Struts Training code for programming How can I dynamically load user-entered data as content of jquery dialog? java webcam integration question java coding Fix Scrollbar position in a checkboxList after postback Information Save Alert Country wise redirection to files Interface in javascript connect database with javascript Zip Code ZipCode how to validate the email login How to play FLV video files on Ipad using HTML code or javascript code? Nitobi Grid is not working in IE10/IE11 jquery issue plese help RegEx Tree structure from json whose parents can be dragged and dropped from child newyorklife insurance getElementById not working javascript code for search in html file Implement The Skeleton Code Implement This Skeleton Code Mobile Automation using Appium Computer forensic application Java: Searching a string from doc files java linked list urgent !!! java linked list urgent!!! library management library management library management library management question Html form using JavaScript to display the table content java how to prevent no from unroundin off on clicking text box again in JSP and Jquery graph generation from xml design file display data from database in textbox when id entered in textbox Javascript Code for all fields how to get HTTP GET request value using javascript array Javascript Querry autocomplete(): Spring mvc with jquery: I am not getting correct value in the text filed. Please help me Create SpreadSheet same as excel using java applet Create SpreadSheet same as excel using java applet How to change focus among multiple select boxes? Write JQUERY Code Write JQUERY Code Converting jsp variable to java variable java

Ads

 
Advertisement null

Ads