witam... zrobilem przy pomocy ajaxu selecty, tak ze jeden wybierajac gatunek, w drugim z tego gatunku pojawiaja sie artykuly. Moj problem polega na tym iz dziala to dla jednego podrzednego selectu. gdy chce dwa, cos mi nie dziala ;/ nie znam sie na funkcji ajax za dobrze wiec mysle ze to cos tu zle robie:
kod JS:
<script type="text/javascript"> var ajax = new sack();
function getRodzList(sel)
{
var Code = sel.options[sel.selectedIndex].value;
document.getElementById('produkt1').options.length = 0; // Empty city select box
if(Code.length>0){
ajax.requestFile = 'por.php?Code='+Code; // Specifying which file to get
ajax.onCompletion = createProd; // Specify function that will be executed after file has been found
ajax.runAJAX(); // Execute AJAX function
}
var Code1 = sel.options[sel.selectedIndex].value;
document.getElementById('produkt2').options.length = 0; // Empty city select box
if(Code1.length>0){
ajax.requestFile = 'por1.php?Code1='+Code1; // Specifying which file to get
ajax.onCompletion = createProd1; // Specify function that will be executed after file has been found
ajax.runAJAX(); // Execute AJAX function
}
}
function createProd()
{
var obj = document.getElementById('produkt1');
eval(ajax.response); // Executing the response from Ajax as Javascript code
}
function createProd1()
{
var obj1 = document.getElementById('produkt2');
eval(ajax.response); // Executing the response from Ajax as Javascript code
}
kod1 i glowna strona:
<form action="porownanie.php" method="get" name="compere"> <table class="szukaj_form">
<td><select id="tworz_rodz" name="tworz_rodz" onchange="getRodzList(this), getRodzList1(this)" > <?PHP
include"connect.php";
$zapytanie="SELECT DISTINCT Rodzaj FROM produkty";
$rezultat=mysql_query($zapytanie);
while($a=mysql_fetch_array($rezultat)){
$rodz1=$a["Rodzaj"];
echo "
}
?>
<td>Produkt:
<select id="produkt1" name="produkt1">
<td>Produkt:
<select id="produkt2" name="produkt2">
<td class="left"><input type="submit" value="Porownaj"/>
kod2 i plik w ktorym pobiera sie dane do drugiego selekta dla drugiego lelecta taki sam tyle ze code1 a nie code:
<?php
{
include"connect.php";
echo "obj.options[obj.options.length] = new Option('".$a['Nazwa']."','".$a['Id']."');";
}
}
?>
bede wdzieczny za sugestie
Ten post edytował gojira 3.06.2008, 11:16:55