09/10/2018, 22:55

Menu số có kết nối CSDL

Mình muốn làm Menu số có kết nối CSDL , vd SONY thì sồ ra các mặt hàng mà SONY sản xuất , tương tự cho SAMSUNG,SANYO,TOSHIBA.Lưu ý là tên hãng và tên lọai sản phẩm lấy từ CSDL chứ không cho nhập tay vô . Mình đã tìm được code cho menu sổ rồi , nhưng sửa lại cho nó lấy từ CSDL thì nó không chạy , có ai giúp mình không?

Đây là mã Menu số không kết nối đến CDSL

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">
.menutitle{
cursor:pointer;
margin-bottom: 5px;
background-color:#ECECFF;
color:#000000;
width:140px;
padding:2px;
text-align:center;
font-weight:bold;
/*/*/border:1px solid #000000;/* */
}

.submenu{
margin-bottom: 0.5em;
}
</style>

<script type="text/javascript">

/***********************************************
* Switch Menu script- by Martial B of http://getElementById.com/
* Modified by Dynamic Drive for format & NS4/IE4 compatibility
* Visit http://www.dynamicdrive.com/ for full source code
***********************************************/

var persistmenu="yes" //"yes" or "no". Make sure each SPAN content contains an incrementing ID starting at 1 (id="sub1", id="sub2", etc)
var persisttype="sitewide" //enter "sitewide" for menu to persist across site, "local" for this page only

if (document.getElementById){ //DynamicDrive.com change
document.write('<style type="text/css"> ')
document.write('.submenu{display: none;} ')
document.write('</style> ')
}

function SwitchMenu(obj){
if(document.getElementById){
var el = document.getElementById(obj);
var ar = document.getElementById("masterdiv").getElementsBy TagName("span"); //DynamicDrive.com change
if(el.style.display != "block"){ //DynamicDrive.com change
for (var i=0; i<ar.length; i++){
if (ar[i].className=="submenu") //DynamicDrive.com change
ar[i].style.display = "none";
}
el.style.display = "block";
}else{
el.style.display = "none";
}
}
}

function get_cookie(Name) {
var search = Name + "="
var returnvalue = "";
if (document.cookie.length > 0) {
offset = document.cookie.indexOf(search)
if (offset != -1) {
offset += search.length
end = document.cookie.indexOf(";", offset);
if (end == -1) end = document.cookie.length;
returnvalue=unescape(document.cookie.substring(off set, end))
}
}
return returnvalue;
}

function onloadfunction(){
if (persistmenu=="yes"){
var cookiename=(persisttype=="sitewide")? "switchmenu" : window.location.pathname
var cookievalue=get_cookie(cookiename)
if (cookievalue!="")
document.getElementById(cookievalue).style.display ="block"
}
}

function savemenustate(){
var inc=1, blockid=""
while (document.getElementById("sub"+inc)){
if (document.getElementById("sub"+inc).style.display= ="block"){
blockid="sub"+inc
break
}
inc++
}
var cookiename=(persisttype=="sitewide")? "switchmenu" : window.location.pathname
var cookievalue=(persisttype=="sitewide")? blockid+";path=/" : blockid
document.cookie=cookiename+"="+cookievalue
}

if (window.addEventListener)
window.addEventListener("load", onloadfunction, false)
else if (window.attachEvent)
window.attachEvent("onload", onloadfunction)
else if (document.getElementById)
window.onload=onloadfunction

if (persistmenu=="yes" && document.getElementById)
window.onunload=savemenustate

</script>
</head>

<body>
<!-- Keep all menus within masterdiv-->
<h2><font color="#FF0000">Management </font></h2>
<div id="masterdiv">


<div class="menutitle" onclick="SwitchMenu('sub1')">Brand </div>
<span class="submenu" id="sub1">
- <a href="new.htm">View Brands</a><br>
- <a href="hot.htm">Insert Brands</a><br>
- <a href="revised.htm">Update Brands</a><br>
- <a href="morezone/">Delete Brands</a><br>
</span>


<div class="menutitle" onclick="SwitchMenu('sub2')">Category </div>
<span class="submenu" id="sub2">
- <a href="list.asp">View Categories</a><br>
- <a href="insert.htm">Insert Categories</a><br>
- <a href="update.asp">Update Categories</a><br>
- <a href="delete.asp">Delete Categories</a>
</span>


<div class="menutitle" onclick="SwitchMenu('sub3')">Product </div>
<span class="submenu" id="sub3">
- <a href="http://www.codingforums.com">View Products</a><br>
- <a href="http://www.codingforums.com">Insert Products</a><br>
- <a href="http://www.codingforums.com">Update Products</a><br>
- <a href="http://www.codingforums.com">Delete Products</a><br>
</span>


<div class="menutitle" onclick="SwitchMenu('sub4')">Feedback </div>
<span class="submenu" id="sub4">
- <a href="http://www.freewarejava.com">View Feedback</a><br>
- <a href="http://www.freewarejava.com">Delete Feedback</a><br> </span>


<div class="menutitle" onclick="SwitchMenu('sub5')">Admin </div>
<span class="submenu" id="sub5"> - <a href="notice.htm">View Admins</a><br>
- <a href="faqs.htm">Insert Admins</a><br>
- <a href="help.htm">Update Admins</a> <br>
- <a href="help.htm">Delete Admins</a> </span>
<p><span class="submenu"> </span></p>
<p><span class="submenu"><br>
</span> </p>
</div>
</body>
</html>
Black Sheep viết 01:03 ngày 10/10/2018
thử xem cái này đi nhé: http://sothink.com/product/dhtmlmenu...hpdb/index.php

có lẽ nó không hoàn toàn là thứ bạn cần nhưng nếu nghiên cứu kỹ một chút thì dùng vẫn tốt lắm...
Genji viết 01:00 ngày 10/10/2018
Nếu nó hướng dẫn bằng ASP thì hay quá , PHP mình đọc không hiểu sắp nộp bài rồi , ngồi mà nghiện cứu chắc trễ hạn quá !
QueenRock viết 01:10 ngày 10/10/2018
mấy cái menu này toàn là javascript, mình nghĩ bạn chỉ cần nắm được cách viết và đặt biến của nó là xong.

Nhìn vào đoạn code trên

<div class="menutitle" onclick="SwitchMenu('sub1')">Brand</div>
<span class="submenu" id="sub1">
- <a href="new.htm">View Brands</a><br>
- <a href="hot.htm">Insert Brands</a><br>
- <a href="revised.htm">Update Brands</a><br>
</span>

phần này được lặp lại, chỉ có phần in đậm là được thay đổi, do đó chỉ cần sử dụng 2 vòng lặp là xong. Tôi chỉ đưa ra gợi ý, còn thực hiện là do bạn

for
<div class="menutitle" onclick="SwitchMenu('sub1')">Brand</div>
<span class="submenu" id="sub1">
for
- <a href="new.htm">View Brands</a><br>
next
</span>
next

nếu không rõ thì mail cho tui phucvd@yahoo.com
suydinhduong viết 01:10 ngày 10/10/2018
Chỉ cần thay mấy label của link đó thành mấy recoerd của recordset thôi mà.
Bài liên quan
0