• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 265
  • Last Modified:

populating listbox by selecting info from other listbox

I am using php on oracle. Using OCI functions I am able to query the table and populate the first list box. How to populate second listbox by selecting option from first listbox and using the same option to populate second listbox by quering another table without refreshing the page?
0
shylaja
Asked:
shylaja
  • 4
  • 2
1 Solution
 
maxkirCommented:
You have to pre-query all possible selections from first listbox and build a lot of Javascript code to change contents of second listbox basing on selection from first listbox. All possible contents for second listbox must be coded in Javasript code, which is, in turn, generated by PHP. IMO, not very simple task - you have to change listbox contents via Javascript.

The main point - u have to build a lot of javascript code using PHP code.
0
 
jasmoft146Commented:
Max is right, however, you can make the task simpler on yourself.

First you take the results of the querys and put each into its own file.

Here's what to do:
in PHP:
While you still have more queries
 query your db
 save the results into a file
go back to top

//Name the files so that the first item in the select box corispondes to the Q0.js; The second item corispondes to Q1.js.

Write the results in the format:
document.write ('<option> $ReturnValue[x] \n'

Then put the options of the second select box in a div with an ID.

<head>
<Script>
function Change(index){
DIV.innerText='<script language="Javascript" src="Q' + index + '.js">'
</Script>
</head>
.....

<select onchange="change(this.selectedIndex);">
.....
<Select ....>
<div ID="DIV">
</Div>
</select>
0
 
maxkirCommented:
Hello?
Did these comments help you ?
0
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
shylajaAuthor Commented:
Thanks a lot maxkir. Your suggestion worked out.
0
 
maxkirCommented:
OK, then you'll probably give me some points ? ;-))
0
 
jasmoft146Commented:
Well, maxkir, you were the first in; however, I must have missed where you posted your code to show how to do it.  I believe you only said that it would take lots of javascript, and neglectied to show how it can be done.
0
 
maxkirCommented:
jasmoft146,
I'm sorry, but the question was how to do it, i.e. the idea. The question wasn't "Give me some example" - so i didn't offer the code.
0

Featured Post

Receive 1:1 tech help

Solve your biggest tech problems alongside global tech experts with 1:1 help.

  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now