473,785 Members | 2,987 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Dynamically Generated dropdown boxes

3 New Member
I've been working on a site with multiple <select> menus that are generated dynamically with PHP and Javascript and I've been using an AJAX approach.

The javascript calls my php page, which hits a database, gets the information I need, then creates XML that is passed back and inserted into a blank <div> tag so you can't see the <select> before.
Ex. of XML created:

[HTML] <Select name="test" onchange="actio n(this.form)">
<Option value = 'id from db'>1</option>
</select>[/HTML]
When you select a new option from this dropdown menu, a new javascript is called and spits back another dropdown menu.
My idea has worked very well in FireFox so far. Pretty slick.

The only problem is they aren't working in IE7.

Any suggestions? Has anyone tried this before? What method did you use? Am I way off? Thanks for the feed back.
Oct 11 '07 #1
2 2061
dmjpro
2,476 Top Contributor
I've been working on a site with multiple <select> menus that are generated dynamically with PHP and Javascript and I've been using an AJAX approach.

The javascript calls my php page, which hits a database, gets the information I need, then creates XML that is passed back and inserted into a blank <div> tag so you can't see the <select> before.
Ex. of XML created:

[HTML] <Select name="test" onchange="actio n(this.form)">
<Option value = 'id from db'>1</option>
</select>[/HTML]
When you select a new option from this dropdown menu, a new javascript is called and spits back another dropdown menu.
My idea has worked very well in FireFox so far. Pretty slick.

The only problem is they aren't working in IE7.

Any suggestions? Has anyone tried this before? What method did you use? Am I way off? Thanks for the feed back.
Post your code so that we can have closer look on your code.

Debasis Jana
Oct 12 '07 #2
climberdude
3 New Member
Okay, I put some code in that I hope helps.
When the page loads I have one drop down for them to select from, Prof.
When the make a selection it goes to my javascript getCourse.

[HTML]<table>
<tr>
<th>Select a professor:</th>
<th id="cHead"></th>
<th id="record"></th>
</tr>
<tr>
<th><form name="myProf">
<select name="Prof" onchange="getCo urse(document.m yProf.Prof)" >

<option value="-1" on></option>
<OPTION VALUE=testusr>T est User</option><OPTION VALUE=climber>A nthony Earl Quinn</option><OPTION VALUE=sellswor> Sharon Ellsworth</option><OPTION VALUE=jlm59>Jar om L McDonald</option> </select></form></th>
<th>
<form name="classes">
<div id="course"></div>
</form>

</th>
<th>
<form name="recording s">
<div id="recording"> </div>
</form>
</th>
</tr>

</table>[/HTML]

Expand|Select|Wrap|Line Numbers
  1.  javascipt
  2. function getCourse(dropdown){
  3.     div = 'course';
  4.     var index= dropdown.selectedIndex;
  5.     var val = dropdown.options[index].value;
  6.     //alert("sending first selection: " + val);
  7.     sendRequest('course.php?netID='+val, val);
  8.     var head = document.getElementById('cHead');
  9.     head.innerHTML= "Select Course:";
  10. }//end getCourse
Here is the sendRequest waits for a reply, when it does this is the code:
Expand|Select|Wrap|Line Numbers
  1. function onReadyState(){
  2.     var ready = req.readyState;
  3.     var data = null;
  4.     if(ready == 4){
  5.         data = req.responseText;
  6.     }
  7.     toConsole(data);
  8. }//end onReady
The code for toConsole
Expand|Select|Wrap|Line Numbers
  1. function toConsole(val){
  2.     var console = document.getElementById(div);
  3.     console.innerHTML = val;
  4. }//end toConsole
On server side some information is sent to course.php which reads the data base and creates an XML document
and sends it back like this.

[PHP]echo $doc->saveXML();[/PHP]

in Firefox it comes back looking like this:
[HTML]
<select name="class" onchange="getRe cording(documen t.classes.class )" id="ie7">
<option>
</option>
<option value="1">
PORT 321
</option>
<option value="5">
SPAN 211
</option>
<option value="6">
PORT 101
</option>
</select>
[/HTML]

When I make a selection here the same process happens only the javascript calls getRecording instead of getCourse to dynamically make another dropdown box. IT works fine in Firefox. In IE it doesn't work. I'm wondering if it has something to do with XML and the innerHTML I'm using in javascript.
Oct 15 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

1
1548
by: Deepa | last post by:
I am doing an ASP.Net application wherein I have a datagrid which I need to populate dynamically. The grid has 5 rows and two columns. In the 2nd col I need to insert dropdown boxes. I'll have to populate both the cols from the database. The values for the 2 cols come from 2 diff tables. How do I do this? Also in the design mode, do I have to manually mention the Collections property of the datagrid columns as Template Columns? This is...
1
1200
by: | last post by:
im dynamically loading dropdown boxes on page.load like this : cbo1.Items.Add("") cbo1.Items.Add("OT") cbo1.Items.Add("ST") cbo1.Items.Add("Ho") cbo1.Items.Add("FMLSK") cbo1.Items.Add("FMLOI") cbo1.Items.Add("FMLPE")
1
7305
by: Daniel Gormley | last post by:
What I have is a form that is dynamically generated based on which database table its calling. Therefore, the number of category.name.count can be different. So I have this form generated and say with x amount of input boxes.. I enter data in the boxes and submit. The data submitted is needing to be placed into an array for insert into a database.
2
1916
by: muthu | last post by:
Hi freinds, In my aspx page i have generated some check boxes dynamically using dhtml. When i check any check box and submit the form,how can i capture the value of check box. How should i identify wich check box is been checked.And the check boxes are not server controls.They are the ordinary html check boxes.Can any one help me out
1
1616
by: Vanyok | last post by:
Hi everyone :) I'm a newb to C-Sharp but more I learn about it - more I like it. I need some help please. I'm trying to find out to dynamically allocate form controls. For example I want to have 5 combo boxes on my form and I want to put the into an array. Can someone point me to some good guide on how to do it or posibly post 'how to' ? Thanks in advance.
5
3446
Tann3r
by: Tann3r | last post by:
Apache.v2.2.4, MySQL.v5.0.27, PHP5.2.1 I have a table of projects which has been dynamically created from an SQL query. I have several dropdown boxes which have been populated from other tables within the database and i would like to filter the information shown in the main table dependant upon the items selected in the dropdown list(s). I assume that this needs to be done using java to enable the list to be refreshed as soon as a dropdown...
0
1570
by: lianaent | last post by:
Hi All, I'm brand new to asp.net 2.0, and have a simple task of just creating a quick and dirty data entry form with SQL Server 2005 on the back end. I added a gridview to my form, and I can populate it dynamically by choosing from a dropdown that I populate dynamically from the database sys.tables table. When I choose a table from my dropdown, poof, the gridview is beautifully loaded with all the columns and rows, and the edit and delete...
8
2933
by: Wingot | last post by:
Hey, I have a program I am trying to write using Visual C#, SQL Server 2005/2008, and Visual Studio 2008, and one part of it includes a Schema called Client. Inside this schema, three tables exist named Country, MedicalCondition, and Customer.
3
1726
by: Charles Packer | last post by:
I need to present a list of options in dropdown list B based on what the user selected in dropdown list A. Both A and B content will be generated dynamically from a database, similar to the way http://cars.com lets the user select the make of a car, which in turn populates a list of models. (That site itself is no help, since the relevant functions don't appear in the source of the page.) A URL of an appropriate Javascript tutorial or...
0
9645
marktang
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...
0
9480
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,...
0
8973
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7499
isladogs
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...
0
5381
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4053
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
2
3647
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2879
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.