Hi codingforums.com,

i have been working on a programm for some time and now i have decided to include some javascript to it and have only very limited knowledge so i copied something from a website and tried to modifiy it but only with partial success. Would be awesome if someone can guide me a littlebit.

So i have 2 select boxes and want the second one to be filled depending on the chosen option from the first one. And 'on the fly' so with imediate change.

So now i have the following code which gives me the first selectbox sucessfully filled with 'customers' in that case but i dont manage to give the second one listed in order, the are all on the same line displayed as one option.

here my code:

Code:
<?php
//read html header
require('html/header.html');

//error display
error_reporting(E_ALL);
ini_set('display_errors', 1);

include('conn.php');
?>
<div align="center">
<form name="classic">
<select name="customer" size="5" onChange="updatesystem(this.selectedIndex)">
<?php
//prepare SQL query
$query = "SELECT * FROM VIA_CUSTOMER ORDER BY ACRONYM ASC";

//parsing sql statement
$statement = oci_parse($conn, $query);

//execute sql statement and display results
if(oci_execute($statement)) {
	while(ocifetchinto($statement, $result, OCI_ASSOC))
	{
		echo "<option align='center' value='".$result['ACRONYM']."'";
		if(isset($_GET['VIA_CUSTOMER']) && $_GET['VIA_CUSTOMER'] == $result['ACRONYM'])
		{
			echo "selected='selected'";
		}
		echo ">".$result['ACRONYM']."</option>";
	}
}
oci_free_statement($statement);
?>
</select>

<select name="system" size="5" style="width: 150px" onClick="alert(this.options[this.options.selectedIndex].value)">
</select>
</form>
</div>

<script type="text/javascript">

var customerlist=document.classic.customer
var systemlist=document.classic.system

var system=new Array()
system[0]=["ARRAY0", "<?php
//prepare SQL query
$query = "SELECT NAME FROM VIA_SYSTEM WHERE IDCUSTOMER = 1 ORDER BY NAME ASC";

//parsing sql statement
$statement = oci_parse($conn, $query);

//execute sql statement and display results
if(oci_execute($statement)) {
	while(ocifetchinto($statement, $result, OCI_ASSOC))
	{
		echo $result['NAME'];
	}
}
oci_free_statement($statement);
?>", "ARRAY0.1", "ARRAY0.2"]
system[1]=["ARRAY1", "ARRAY1.1", "ARRAY1.2"]
system[2]=["ARRAY2"]
system[3]=["ARRAY3"]
system[4]=["ARRAY4"]

function updatesystem(selectedsystemgroup){
systemlist.options.length=0
if (selectedsystemgroup>=0){
for (i=0; i<system[selectedsystemgroup].length; i++)
systemlist.options[systemlist.options.length]=new Option(system[selectedsystemgroup][i].split("|")[0], system[selectedsystemgroup][i].split("|")[1])
}
}

</script>
<?
//include html footer
require('html/footer.html');
?>
now my problem is within this piece of code:

Code:
<?php
//prepare SQL query
$query = "SELECT NAME FROM VIA_SYSTEM WHERE IDCUSTOMER = 1 ORDER BY NAME ASC";

//parsing sql statement
$statement = oci_parse($conn, $query);

//execute sql statement and display results
if(oci_execute($statement)) {
	while(ocifetchinto($statement, $result, OCI_ASSOC))
	{
		echo $result['NAME'];
	}
}
oci_free_statement($statement);
?>
how can i get the
Code:
WHERE IDCUSTOMER = 1
to be chosen from the first select box because $_GET wont work obviously

and how can i display the results all as single arrays and not one single line?

i know this might be a lot to ask but im still learning and cant get past this with just searching google.

This is a picture of the output, the first select is good but the second one is the issue and the 'ARRAY0.1' is just dummy data (not from database)



so it should be displayed as single lines like so:
LSM
SQL*LIMS
TEST

i would be eternally grateful for whom can help me out with this.

Regards,
The Noob