Hej
Har indsat <form method=\"POST\" action=\"addtocart.php\"> men den viser stadig ikke noget
Har du forstand på java?- for jeg prøver at få flette en rulle menu ind, der automatisk opdaterer sig se eks. her:
http://roenving.users.whitehat.dk/WD4Selects-beta.html
og jeg har sådan set koden, men jeg kan ikke finde ud af og få sat den ind!
visvare koden:
<?php
//connect to database
require("mysql.php");
$conn = mysql_connect($server, $brugernavn, $adgangskode)
or die(mysql_error());
mysql_select_db($database,$conn)
or die(mysql_error());
$display_block = "<h1>Detaljer om varen</h1>";
//validering af varen
$get_items = "SELECT c.name, si.name, si.price, si.description, si.picture FROM inventory AS si left join category AS c ON c.id = si.category WHERE si.id = '".$_GET['item_id']."'";
$get_items_res = mysql_query($get_items)
or die (mysql_error());
if (mysql_num_rows($get_items_res) <1) {
//varen ikke valid
$display_block .= "<p><em>Invalid vare valg</em></p>";
} else {
//varen ok, hent oplysninger
$name = strtoupper(stripslashes(mysql_result($get_items_res,0,'name')));
$price = mysql_result($get_items_res,0,'price');
$description = stripslashes(mysql_result($get_items_res,0,'description'));
$picture = mysql_result($get_items_res,0,'picture');
//Lav et "brødkrummespor"
$display_block .= "<p><strong><em>Du ser på:</em><br/>";
$display_block .= $name."</strong></p>";
$display_block .= "<table cellpadding=3 cellspacing=3>";
$display_block .= "<tr><td valign=middle align=center><img src=\"".$picture."\"></td><td valign=middle><P><strong>Beskrivelse:</strong><br>".$description."</p><p><strong>Pris:</strong> kr. ".$price."</p><form method=\"POST\" action=\"addtocart.php\">";
//hent størrelser
$get_sizes = "SELECT item_size FROM store_item_size where item_id='".$_GET['item_id']."' ORDER BY item_size";
$get_sizes_res = mysql_query($get_sizes)
or die(mysql_error());
if (mysql_num_rows($get_sizes_res) > 0) {
$display_block .= "<p><strong>Findes i størrelserne og farverne: </strong><select name=\"sel_item_size\" onchange=\"javascript:document.Size.submit();\">";
while ($sizes = mysql_fetch_array($get_sizes_res)) {
$item_size = $sizes['item_size'];
$display_block .= "<option value=\"".$item_size."\">".$item_size."</option>";
}
$display_block .= "</select>";
}
//hent antal
$get_qty = "SELECT store_item_qty FROM store_item_size where item_id = ".$_GET['item_id']." ORDER BY store_item_qty";
$get_qty_res = mysql_query($get_qty)
or die(mysql_error());
if (mysql_num_rows($get_qty_res) > 0) {
$display_block .= "<P><strong>Antal: </strong><select name=\"sel_item_qty\" onchange=\"javascript:document.Size.submit();\">";
while ($qty = mysql_fetch_array($get_qty_res)) {
$store_item_qty = $qty['store_item_qty'];
$display_block .= "<option value=\"".$store_item_qty."\">".$store_item_qty."</option>";
for ($i=1; $i<$qty['store_item_qty']; $i++) {
$display_block .= "<option value=\"".$i."\">".$i."</option>";
}
}
$display_block .= "</select>";
}
$display_block .= "</select><input type=\"hidden\" name=\"sel_item_id\" value=\"".$_GET['item_id']."\"><P><input type=\"submit\" name=\"submit\" value=\"Tilføj til indkøbsvognen\"></p></form></td></tr></table>";
}
mysql_close($conn);
?>
<html>
<head>
<title></title>
<link rel="stylesheet" type="text/css" href="rullepanel.css">
<style>
a {text-decoration: none}
</style>
</head>
<body>
<? print $display_block; ?>
</body>
</html>
drop menu koden:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"
http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Smart selects</title>
<meta name="Generator" content="Stone's WebWriter 4">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link HREF="style/style.css" REL="stylesheet" TYPE="text/css">
<style type="text/css">
body{padding:10px;font-family:Tahoma,Verdana,Arial,sans-serif;text-align:center;background:#EBD3E2;line-height:1.5;overflow:hidden;}
</style>
<script language="javascript" type="text/javascript">
var arr = [
["Valg 1",
["2. valg 1 (1)","2. valg 2 (1)","2. valg 3 (1)"]],
["Valg 2",
["2. valg 1 (2)","2. valg 2 (2)","2. valg 3 (2)","2. valg 4 (2)"]],
["Valg 3",
["2. valg 1 (3)","2. valg 2 (3)","2. valg 3 (3)","2. valg 4 (3)","2. valg 5 (3)"]]
];
function initSels(){
createOpts(document.getElementById('sel1'));
}
function createOpts(sel){
var s = new Array();
var num = 0, txt = "arr";
var ar = opt = null;
var n = sel.selectedIndex;
var args = createOpts.arguments.length;
for(var i=1;args>i;i++){
s[i-1] = document.getElementById(createOpts.arguments[i]);
if(s[i-1]==sel)num=i;
}
if(args>1){
if(s[num])sel = s[num];
else return;
}
if(n==0&&args>1){
for(i=num;args>i+1;i++){
s[i].length = 0;
opt = document.createElement('OPTION');
s[i].appendChild(opt);
opt.value = "";
opt.text = "\74-- Vælg --";
}
return true
};
for(i=0;num>i;i++){
txt+="["+(s[i].selectedIndex-1)+"][1]";
}
ar = eval(txt);
sel.length = 0;
opt = document.createElement('OPTION');
sel.appendChild(opt);
opt.value = "";
opt.text = "-- Vælg --";
for(i=0;ar.length>i;i++){
opt = document.createElement('OPTION');
sel.appendChild(opt);
if(typeof ar[i] == 'object'){
opt.value = ar[i][0];
opt.text = ar[i][0];
}else{
opt.value = ar[i];
opt.text = ar[i];
}
}
if(args>num+2){
for(i=num+1;args-1>i;i++){
s[i].length = 0;
opt = document.createElement('OPTION');
s[i].appendChild(opt);
opt.value = "";
opt.text = "\74-- Vælg --";
}
}
}
</script>
</head>
<body onload="initSels()">
<form name="sels" action="
http://roenving.users.whitehat.dk" onsubmit="return false;">
To afhængige selects:
<select name="sel1" id="sel1" onchange="createOpts(this,'sel1','sel2');">
<option value="" selected>Vis alle</option>
</select>
<select name="sel2" id="sel2">
<option value="" selected
><-- Vælg --</option>
</select></form>
</body>
</html>
Håber du kan hjæpe