|
|
|
| Подскажите как правильно модернизировать функцию.
Существует код который переписывает значения выбирая данные из бвзы данных
на данный момент эти поля переписываются в зависимости от переменной markiа а мне надо что бы была зависимость еще и от переменной
jQuery(function($) {
$(document).ready(function() {
$(".marka").change(function(){
$tr = $($(this).parent()).parent(); // select the parent <tr> element
$marka = ($tr.children()).children("select.marka"); // looking for the child class #marka
$sechenie = ($tr.children()).children("select.sechenie"); // looking for the child class #sechenie
$kolichestvo = ($tr.children()).children(".kolichestvo"); // looking for the child class #kolichestvo
$cena2_ = ($tr.children()).children(".cena2_"); // looking for the child class #cena
$summa = ($tr.children()).children(".summa"); // looking for the child class #summa
$ed_izmer2_ = ($tr.children()).children(".ed_izmer2_"); // looking for the child class #ed_izmer
GetSechenie($marka.val(),$sechenie);
GetCena($marka.val(),$cena2_,$sechenie.val());
GetEd_Izmer($marka.val(),$ed_izmer2_,$sechenie.val());
setTimeout(function() { CalcTr($tr); }, 500);
});
});
});
function GetEd_Izmer(marka,ed_izmer2_,sechenie) {
jQuery(function($){
$.post( "get.php",
{ type: "text",
marka: marka,
sechenie: sechenie,
vid: "izm",
},
function(data){
$ed_izmer2_.attr('value', data);
}
);
});
}
function GetCena(marka,cena2_,sechenie) {
jQuery(function($){
$.post( "get.php",
{ type: "text",
marka: marka,
sechenie: sechenie,
vid: "cena2_",
},
function(data){
$cena2_.attr('value', data);
}
);
});
}
function GetSechenie(marka,sechenie) {
jQuery(function($){
$.post( "get.php",
{ type: "text",
marka: marka,
vid: "sechenie",
},
function(data){
$sechenie.children('option').remove();
$sechenie.append(data);
}
);
});
}
|
код файла get.php
$marka = iconv("UTF-8", "windows-1251", $_POST['marka']);
$vid = iconv("UTF-8", "windows-1251", $_POST['vid']);
$marka = $_POST['marka'];
$vid = $_POST['vid'];
$marka = $_POST['marka'];
$vid = $_POST['vid']; */
$sql = mysql_connect("localhost", "urpakru8_Germet", "rtyu56sdsGG");
mysql_select_db("urpakru8_joomla", $sql);
if($vid == "sechenie"){
$query = "SELECT name FROM jos_sechenia WHERE mname='".$marka."'";
$res = mysql_query($query);
while ($row = mysql_fetch_assoc($res)) {
echo '<option>'.$row['name'].'</option>';
}
}
if($vid == "cena2_"){
$query = "SELECT cena2_ FROM jos_sechenia WHERE mname='".$marka."'";
$res = mysql_query($query);
$row = mysql_fetch_assoc($res);
echo $row['cena'];
}
if($vid == "izm"){
$query = "SELECT ed_izmer2_ FROM jos_sechenia WHERE mname='".$marka."'";
$res = mysql_query($query);
$row = mysql_fetch_assoc($res);
echo $row['ed_izmer2_'];
}
mysql_close($sql);
|
| |
|
|