09/10/2018, 17:39

[Q] cuu gap!!!!!!!!!!!!!

các bác ơi cứu gấp: vốn mình lập trình PHP&MYSQL dung 2 combo quan he 1-n (một nhiều) khi click combo 1 thi o combo 2 se hien nhung mẫu tin nào có quan he voi combo 1 lam da duoc roi nhung khong hien duoc tiếng việt (unicode). Ban nao lam duoc xin chi giup neu gui code kem theo cang tot xin cam on
tulipden viết 19:45 ngày 09/10/2018
Để cho combo hiển thị được tiếng việt thì bạn cho font của cái combo ấy là arial hay verdana ấy
Ví dụ:<select name='combo1' style='font-family:arial,verdana'>
<option value='...'>...</option>
</select>
Đại khái là thế
lang viết 19:43 ngày 09/10/2018
OK minh cam on Ban ve su tra loi nhanh chong cua Ban
doi voi cach ban dua ra chi dung cho 1 combo thoi va khong co dung javascript con truong hop cua minh dung javascript de the hien no khong phai action tro lai khi minh chon combo cha, chi load luc ban dau ma thoi va du lieu duoc luu tru trong 2 table duoc lay dua vao javascript (table cha la:towns table con la:tructhuoc)
code nhu sau:
<?

require"../../connect/connect.php"; //file nay connect de chon database

?>

<SCRIPT language=javascript>
function selectCity() {
var city = document.checkForm.city.value;
displayDistrict(city);
}

function displayDistrict(city) {
city = parseInt(city);
var t;
var dist =new Array(2);
dist[0] =new Array(getDistrict(city).length);
dist[1] =new Array(getDistrict(city).length);

dist[0].length=0;
dist[1].length=0;
dist[0] = getDistrict(city)[0];
dist[1] = getDistrict(city)[1];

document.checkForm.dis.length=0;

for (var i = 0; i < dist[0].length; i++) {
jeans = new Option(dist[0][i]);
document.checkForm.dis.options[i] = jeans;
}
document.checkForm.dis.options[0].selected = true;

for (var i = 0; i < dist[1].length; i++) {
document.checkForm.dis.options[i].value = dist[1][i];
}
}

</SCRIPT>

<SCRIPT language=JavaScript type=text/javascript>
function getDistrict(city)
{
var dis = new Array(2);
dis[0] = new Array();
dis[1] = new Array();
<?
$result=mysql_query("select * from towns order by id asc");
while(($result)&&($diem=mysql_fetch_row($result)))
{
?>
if (city==<?echo $diem[0]?> )
{
<?
$resulttruc=mysql_query("select * from tructhuoc where idtown = '$diem[0]'");
$j=0;
while(($result)&&($truc=mysql_fetch_row($resulttru c)))
{
?>
dis[0][<?echo $j?>]='<?echo $truc[2]?>'; //gia tri can hien tieng viet
dis[1][<?echo $j?>]='<?echo $truc[0]?>'; //id xac dinh ben duoi chuong trinh
<?
$j++;
}
?>
}
<?
}
?>
return (dis);
}
</SCRIPT>

<FORM action="" method=post name=checkForm>

<TABLE border=0 cellPadding=1 cellSpacing=0 width="100%">
<TBODY>
<TR>
<TD align=right vAlign=top width=150>Ti***777;nh/tha***768;nh </TD>
<TD vAlign=top>
<SELECT name=city onchange=selectCity() style="font-family:verdana" >
<?
$result=mysql_query("select * from towns order by id asc");
$i=0;
while(($result)&&($diem=mysql_fetch_row($result)))
{
?>
<option value="<?echo $diem[0]?>" <?if ($diem[0]==$diadiem) echo"selected";?>><?echo $diem[2]?></option>
<?
}
$i++;
?>
</SELECT>
</TD>
</TR>
<TR>
<TD align=right valign=top width=150>Quâ***803;n/huyê***803;n </TD>
<TD vAlign=top>
<SELECT style="font-family:verdana" name=dis>
<?
$result=mysql_query("select * from tructhuoc");
$i=0;
while(($result)&&($truc=mysql_fetch_row($result)))
{
?>
<option value="<?echo $truc[0]?>"><?echo $truc[2]?></option>
<?
}
$i++;
?>
</SELECT>
</TD>
</TR>

</table>
ban xem cach su dung cua minh co toi uu khong? va su dung tieng viet trong truong hop nay minh phai lam sao nhe neu co cach nao hay hon ban post len giup minh cam on truoc
tulipden viết 19:45 ngày 09/10/2018
Hơi lộn xộn một chút. Đợi mình bố trí lại đọc xem. Nếu chỉ hiển thị đúng unicode trong combo thì chỉ cần style kia là đủ rồi. Chỉ sợ là khi nhập vào cơ sở dữ liệu, bạn đã không nhập đúng unicode thôi.
Còn đoạn code trên của bạn. MÌnh nghĩ là bạn nên đọc và xử lý cơ sở dữ liệu trước, sau đó đưa vào mã html sau.
lang viết 19:46 ngày 09/10/2018
minh muon no the hien giong nhu site www.nhadat.com (trang dang tin do dang ky moi) Ban nhin xem no dep lam sao tieng viet ra day du (minh noi ve mat xu ly tieng viet) khi click vao tinh/thanh thi lap tuc no hien ra quan/huyen khong co chop mot cai dau va tieng viet ra rat day du ban a minh raty muon lam nhu vay nhung khong lam duoc (nhat dinh hoc hoi)
Bài liên quan
0