Hi,
am trying to create dynamic drop down boxes..
there are 3 drop down boxes.
The second drop down box elements are to be update based on the selection made in the first drop down box (selecting an element on the first drop down box calls a getData.jsp file which returns the result.)
the third drop down box elements are to be update based on the selection made in the second drop down box (selecting an element on the second drop down box calls a getData.jsp file which returns the result.)
Can you help me with this....?
3 2542 acoder 16,027
Recognized Expert Moderator MVP
I assume that you're going to use Ajax for this. What code do you have so far?
I assume that you're going to use Ajax for this. What code do you have so far?
JavaScript part -
var xmlHttp
-
var hint_about
-
-
function setAbout(stri)
-
{
-
hint_about = stri;
-
}
-
-
function getAbout()
-
{
-
return hint_about;
-
}
-
-
function showHint(st, lin, about)
-
{
-
if (st.length==0)
-
{
-
document.getElementById(about).innerHTML="";
-
return;
-
}
-
xmlHttp=GetXmlHttpObject()
-
if (xmlHttp==null)
-
{
-
alert ("Your browser does not support AJAX!");
-
return;
-
}
-
var url=lin;
-
url=url+"?q="+st;
-
url=url+"&sid="+Math.random();
-
xmlHttp.onreadystatechange=stateChanged;
-
xmlHttp.open("GET",url,true);
-
xmlHttp.send(null);
-
}
-
-
function stateChanged()
-
{
-
if (xmlHttp.readyState==4)
-
{
-
var temp = getAbout();
-
document.getElementById(temp).innerHTML=xmlHttp.responseText;
-
}
-
}
-
-
function GetXmlHttpObject()
-
{
-
var xmlHttp=null;
-
try
-
{
-
// Firefox, Opera 8.0+, Safari
-
xmlHttp=new XMLHttpRequest();
-
}
-
catch (e)
-
{
-
// Internet Explorer
-
try
-
{
-
xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
-
}
-
catch (e)
-
{
-
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
-
}
-
}
-
return xmlHttp;
-
}
-
-
-
function elementExchange(eleID)
-
{
-
loadArray();
-
-
var i =0
-
for(i=0;i<jsArray.length;i++)
-
{
-
var optn = document.createElement("OPTION");
-
optn.value=jsArray[i]
-
optn.text=jsArray[i]
-
document.getElementById(eleID).options.add(optn)
-
} // end of for
-
-
} // end of elementExchange()
-
-
Below is where it is supposed to be updated -
<tr>
-
<td align="center">
-
-
<select size="1" name="asset_type1" onclick="setAbout('temp_choice'); showHint(this.value, '/asset/jsps/ajaxGetMake.jsp'); elementExchange('make1');"><%out.print(opts);%></select></td>
-
<td align="center">
-
<select size="1" name="make1" onclick="showHint(this.value, '/asset/jsps/ajaxGetModel.jsp'); setAbout('model1');"></select></td>
-
<td align="center">
-
<select size="1" name="model1" onclick="showHint(this.value, '/asset/jsps/ajaxGetAssetTag.jsp'); setAbout('asset_tag1');"></select></td>
-
<td align="center"><select size="1" name="asset_tag1" onclick="document.asset.asset_tag2.value = this.value;"></select></td>
-
</tr>
-
-
-
-
<form name="temp_form">
-
<div id='temp_choice' style='display:none'></div>
-
</form>
-
acoder 16,027
Recognized Expert Moderator MVP
If the response from the server-side returns the options as HTML, just use innerHTML to set the options. If not, parse the response to get the options andset them. Don't only use the add method with one parameter. That only works in IE. See this link.
Once you have one working, we'll worry about the third dropdown box.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Dan |
last post by:
Can anyone offer suggestions on how to do this or if it is possible?
I have a form that uses a drop down box and 2 text fields.
What I am trying to do is have the value of each text box set by the
choice from the drop down box.
Something like:
<form name="populatefrm" id="contactfrm" method="post"
|
by: Michael |
last post by:
Need some help trying to read values from web controls - specifically
*finding* the controls (like a drop down list) - that are added
dynamically added within an asp:panel control.
The page contains multiple panels within the form. The panels appear
at different times - for our argument, let's say panel 1 appears
first, users clicks a submit button and then
panel 1 disappears and panel 2 appears, etc.
When clicks on the submit button...
|
by: Brian Shannon |
last post by:
I have 3 combo boxes and two date text boxes on a .aspx page. The user can
fill in any of the 5 controls or none to filter a datagrid. I was hoping
someone could explain how to efficiently build the where clause of a sql
string to send to SQL 2000 for a data set.
Currenly I check each control with an IF statement to determine if something
is filled in. If there is I begin building the where clause. Below is what
I have done (and it...
|
by: Yoshitha |
last post by:
hi
I have 2 drop down lists in my application.1st list ontains itmes like
java,jsp,swings,vb.net etc.2nd list contains percentage i.e it conatains the
items like 50,60,70,80,90,100.
i will select any skill in 1st drop down list then i'll select % of this
skill in the 2nd list box , based on the percentage i've selected in the 2nd
list box it has to display
2 sets of drop down list boxes at run time one for selecting skill and
|
by: taras.di |
last post by:
Hi everyone,
I've been reading up on how to create a drop down box who's context is
dynamically produced based on the value of a previous select box. I've
read a lot about some of the browsers not properly readjusting the
width of a dynamically produced drop down box, and some browsers having
problems adjusting the height and widths (most notably NN). Most
solutions involve manually refreshing the browser window and/or padding
the...
| |
by: dynamitez |
last post by:
Hi there, I need some help!
I want to create 2 dependent dynamic drop down boxes which choices of box 2 depends on the choice chosen from box 1.
Ex.
Box1
-western
-eastern
Box2
(If western is chosen)
|
by: bytesFTW99 |
last post by:
I have been struggling with this for some time can anyone help out? just trying to have 3 dropdown boxes that fill depending on what is selected, then in some cases click a button and have the second set of 3 dropdown boxes be filled with the same values.
thank you
<head>
<SCRIPT LANGUAGE="JavaScript" type="text/javascript">
var firstChoice2 = 0;
var secondChoice2 = 0;
|
by: happyman992 |
last post by:
Hi,
I have 2 questions. First, I am building a form with multiple drop down boxes. The options of the second drop down box will depend on what the user chooses on the first, options of the third drop down box depend on what they choose on the second, etc. The values of each option are inside a database which I can query for and put into a php array. I am wondering what is the easiest way to build this.
Second, when this form is...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |