Hola,a ver si me podeis hechar una mano:
Tengo un formulario con 4 campos,dos son de input y otros dos son de listas desplegables,una de ellas funciona,que lista paises y segun elijas el pais te saca en otra lista de los clientes de ese pais y la lista desplegable que no funciona es por compañia y hace lo mismo,eliges una compañia y en otra lista te tiene que sacar quien trabaja en esa compañia.Lo que hace ahora es recargar y luego volver al formulario sin hacer nada..os muestro el codigo por si veis algun fallo,yo ya no se que hacer,llevo 3 dias detras de esto:
Os pongo tambien el codigo de la funcion que que lista paises y si funciona:
Funcion de paises(Funciona correctamente):
function country_select(&$tpl,$country)
{
global $MySQL;
global $COLOR;
global $HTTP_SESSION_VARS;
$sql = "select
country,
code
from
countries
order by country
";
$result = send_sql($MySQL->db1, $sql);
//echo (mysql_num_rows($result)."<br>");
if (!$result)
{
die ("Database Error");
}
$option_line='<OPTION value="">Select a country';
while ($value=mysql_fetch_array($result))
{
$countries= $value[0];
$code = $value[1];
if($countries == $country){
$option ='<OPTION value="'.$countries.'" selected>'.$countries.'';
}
else{
$option ='<OPTION value="'.$countries.'">'.$countries.'';
}
$option_line=$option_line.$option;
}
$tpl->assign(COUNTRY,$option_line);
}
Esta es la funcion que tiene algun fallo...
function company_select(&$tpl,$companylist_html)
{
global $MySQL;
global $HTTP_SESSION_VARS;
$sql = "select
company, cus_id
from
customers
group by
company";
//echo $companylist_html;
$result = send_sql($MySQL->db1, $sql);
if (!$result)
{
die ("Database Error");
}
$option_line='<option value="">Select Company';
while ($value=mysql_fetch_array($result))
//echo ($value["company"]);
{
$companylist_name=$value[0];
$cus_id= $value[1];
$option='<OPTION value='.$companylist_name;
if ($companylist_name==$companylist_html)
{
//echo('enter_here--');
$option=$option.' selected';
}
$option=$option.'>'.$companylist_name.'';
$option_line=$option_line.$option;
}
//$option_line=$option_line."<option value=test>what is selected:".$companylist_html."</option>";
$tpl->assign(COMPANYLIST, $option_line);
}
Y este es el template donde estan los inputs y las listas desplegables:
<html><head>
<title>Edit</title>
<link href="templates/style/buttons.css" type=text/css rel=stylesheet>
<link href="templates/style/W3C-REC.css" type=text/css rel=stylesheet>
<script language="JavaScript" type="text/javascript">
<!--
var bV=parseInt(navigator.appVersion);
NS4=(document.layers)&&(bV>=4) ? true : false;
IE4=((document.all)&&(bV>=4)) ? true : false;
DOM= (!document.layers && !document.all && bV>=4) ? true : false; // A hack to guess if the browser supports the DOM
capable = (NS4 || IE4 || DOM) ? true : false;
function expandIt(){return;}
//-->
</script>
</head>
<body {color} background="images/topBG2.png">
<script language="JavaScript" type="text/javascript" src="templates/FX.js">
<!--
alert("Error, It Can't Load JavaScript LIBRARY");
//-->
</script>
<script>
function recall(form,control)
{
//dir = "select_customer.php?letter="+document.forms[0].elements['letter'].value;
// alert(control);
window.location.href = "select_customer.php?services_html="+document.form s[0].elements['services_html'].value+"&letter="+document.forms[0].elements['letter'].value+"&country_html="+document.forms[0].elements['country_html'].value+"&companylist_html="+document.forms[0].elements['companylist_html'].value;
}
</script>
<form method="POST" action="{SCRIPT}">
<table width = 535 height="1" bordercolor="#000080" border="0">
<tr>
<td width="20" valign="bottom">
<table>
<tr>
<td>
<font> <B>Alphabetical Sort</B></font> <br>
<select name="letter" style="width:210px" size="1" onchange=recall(this.form,"letter") >
<option value="" selected>Empty
<option value="" >All
{TABLE_ROW_1}
</select>
<br>
<font> <B>Country</B></font> <br>
<select name="country_html" style="width:210px" size="1" onchange=recall(this.form,"country")>
{COUNTRY}
</select>
<br>
<font> <B>Services List</B></font> <br>
<select name="services_html" style="width:210px" size="1" onchange=recall(this.form,"services")>
{SERVICES}
</select>
<br>
<font><B>Company </B> </font><br>
<select name="companylist_html" style="width:210px" size="1" onchange=recall(this.form,"companylist")>
{COMPANYLIST}
</select>
</td>
</tr>
</table>
<td width="50" valign="bottom">
<table heigth="10">
<font><B> Customers List</B></font><br>
<select name=id style="width:265px" size="5">
{TABLE_ROW}
</select>
</td>
<td width ="30" align="center" valign="bottom">
{BUTTONS}
</td>
</table>
</td>
</tr>
</table>
</form>
</body>
</html>
Muchas gracias!!!!