SyntaxError:应为表达式,Get';}'-php html和javascript
我正在制作一个网络应用程序,在我们学校的酒吧里买三明治。在菜单部分,当我单击三明治时,它会给我以下问题:SyntaxError:应为表达式,Get';}'-php html和javascript,javascript,php,html,Javascript,Php,Html,我正在制作一个网络应用程序,在我们学校的酒吧里买三明治。在菜单部分,当我单击三明治时,它会给我以下问题: SyntaxError:应为表达式,在菜单上获得“}”。php:2 代码如下: <?php include_once 'navbar.php'; include_once '..\PHP\dbh-inc.php'; ?> <DOCTYPE! html> <html> <head> <title>Bar Giua<
SyntaxError:应为表达式,在菜单上获得“}”。php:2 代码如下:
<?php
include_once 'navbar.php';
include_once '..\PHP\dbh-inc.php';
?>
<DOCTYPE! html>
<html>
<head>
<title>Bar Giua</title>
<link rel="stylesheet" href="../Resources/CSS/stili.css" type="text/css" />
</head>
<body>
<center>
<!--Links tab-->
<div>
<button class="tablinks" onclick="openMenu(event, 'Cibo')">Cibo</button>
<button class="tablinks" onclick="openMenu(event, 'Bevande')">Bevande</button>
<button class="tablinks" onclick="openMenu(event, 'Caffetteria')">Caffetteria</button>
<button class="tablinks" onclick="openMenu(event, 'Altro')">Altro</button>
</div>
<!--Contenuto tab-->
<!--CIBO-->
<div align="left" id="Cibo" class="tabcontent">
<?php
$qcibo = "SELECT Prodotti.Nome,Prodotti.Prezzo FROM Prodotti,CategorieProdotti WHERE Prodotti.Categorie = CategorieProdotti.id AND CategorieProdotti.Descrizione = 'panini';";
$result = mysqli_query($conn, $qcibo);
if(mysqli_num_rows($result) !=0){
while($row = mysqli_fetch_array($result, MYSQLI_ASSOC)){
echo "<button class='icone' onclick='openOrdine(event, 'Ordine')'></button>";
//echo $row["Nome"].$row["Prezzo"]."<br>";
}
}
?>
</div>
<!--BEVANDE-->
<div align="left" id="Bevande" class="tabcontent">
<?php
$qbevande = "SELECT Prodotti.Nome,Prodotti.Prezzo FROM Prodotti,CategorieProdotti WHERE Prodotti.Categorie = CategorieProdotti.id AND CategorieProdotti.Descrizione = 'bevande';";
$result = mysqli_query($conn, $qbevande);
if(mysqli_num_rows($result) !=0){
while($row = mysqli_fetch_array($result, MYSQLI_ASSOC)){
echo "<input type='button' class='icone' onclick='openOrdine(event, 'Ordine')'>";
//echo $row["Nome"].$row["Prezzo"]."<br>";
}
}
?>
</div>
<!--CAFFETTERIA-->
<div align="left" id="Caffetteria" class="tabcontent">
<?php
$qcafeteria = "SELECT Prodotti.Nome,Prodotti.Prezzo FROM Prodotti,CategorieProdotti WHERE Prodotti.Categorie = CategorieProdotti.id AND CategorieProdotti.Descrizione = 'Cafeteria';";
$result = mysqli_query($conn, $qcafeteria);
if(mysqli_num_rows($result) !=0){
while($row = mysqli_fetch_array($result, MYSQLI_ASSOC)){
echo "<input type='button' class='icone' onclick='openOrdine(event, 'Ordine')'>";
//echo $row["Nome"].$row["Prezzo"]."<br>";
}
}
?>
</div>
<!--ALTRO-->
<div align="left" id="Altro" class="tabcontent">
<?php
$qaltro = "SELECT Prodotti.Nome,Prodotti.Prezzo FROM Prodotti,CategorieProdotti WHERE Prodotti.Categorie = CategorieProdotti.id AND CategorieProdotti.Descrizione = 'altro';";
$result = mysqli_query($conn, $qaltro);
if(mysqli_num_rows($result) !=0){
while($row = mysqli_fetch_array($result, MYSQLI_ASSOC)){
echo "<input type='button' class='icone' onclick='openOrdine(event, 'Ordine')'>";
//echo $row["Nome"].$row["Prezzo"]."<br>";
}
}
?>
</div>
<div style="height: 100px" align="left" id="Ordine" class="tabcontent0">
<h2 class="classep"></h2>
<div class="inner">
<div class="button">
<input type="button" class="tasti" value="-" onclick="ordineMeno()">
<input type="text" class="textbox" value="1" id="numeroOrdine">
<input type="button" class="tasti" value="+" onclick="ordinePiu()">
<input type="checkbox" style="width:15px; height: 15px;" id="infarinato" name="Infarinato">
<a style="font-size: 20px;"> Infarinato </a>
</div>
<input type="button" class="submit" value="Submit" onclick="addOrdine()">
</div>
</div>
</center>
<form method="post" action="/carrello.php">
<textarea id="hide"></textarea>
<button type="submit">
</form>
</body>
<script>
function ordinePiu(){
var numOrd = document.getElementById('numeroOrdine').value;
numOrd = parseInt(numOrd);
numeroOrdine.value = numOrd + 1;
}
function ordineMeno(){
var numOrd = document.getElementById('numeroOrdine').value;
numOrd = parseInt(numOrd);
if(numOrd > 0){
numeroOrdine.value = numOrd - 1;
}
}
function openMenu(evt, menu){
var i, tabcontent, tablinks;
tabcontent = document.getElementsByClassName("tabcontent");
for (i = 0; i < tabcontent.length; i++) {
tabcontent[i].style.display = "none";
}
tablinks = document.getElementsByClassName("tablinks");
for (i = 0; i < tablinks.length; i++) {
tablinks[i].className = tablinks[i].className.replace(" active", "");
}
document.getElementById(menu).style.display = "block";
evt.currentTarget.className += " active";
}
function openOrdine(evt0, menu0){
var i0, tabcontent0, tablinks0;
tabcontent0 = document.getElementsByClassName("tabcontent0");
for (i0 = 0; i0 < tabcontent0.length; i0++) {
tabcontent0[i0].style.display = "none";
}
document.getElementById(menu0).style.display = "block";
evt0.currentTarget.className += " active";
}
function addOrdine(){
Test
}
</script>
</html>
巴吉亚
磁波
贝凡德
咖啡
阿尔特罗
我打赌:
function addOrdine(){
Test
}
将适当的代码放在那里,或注释您的行过多的代码。您需要自己更好地解决这个问题。我们不是调试器。您需要隔离问题并从中进行调试。如果你陷入困境,请清楚地解释什么东西不适合你。我建议你读一个好的问题和答案。另外,请确保使用并阅读“SyntaxError:expected expression,Get…”是一个JavaScript错误。您的上一个函数只在其内部显示“Test”。它的意思是SyntaxError:expected expression,在Menu.php:2.上获得“}”。但我想您还没有附加这个函数。你能附上这个吗?也许我们可以整理一下this@TaylorRahul我猜URL是“Menu.php”,因为它是一个三明治菜单。你能附加一个屏幕吗?肯定是这个。这是“提交”按钮的单击处理程序。@LeeKowalkowski这可能是一个问题,但这不是他所要求的。。对于这种情况,它不会说SyntaxError。。它将类似于未定义的etcit测试未定义它确实会。我在编写此测试之前就遇到了此问题,无论如何,我在单击openOrdine函数时遇到了此问题:/
<?php
session_start();
?>
<!DOCTYPE html>
<html lang="en">
<head>
<title>Bar Giua</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<!--BOOTSTRAP-->
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<!--NOSTRI FILE-->
<link rel="stylesheet" href="..\Resources\CSS\TendinaDefault.css" type="text/css" />
<style>
body {
font-size: 28px;
background-color: #868686;
}
</style>
</head>
<body>
<!--<div id="login_bar" style="text-align: right">
<ul id="login_signup">
<li><a href="#" id="login_link">Login <span>◀</span></a></li>
<li><a href="#" id="sign_link">SignUp <span>◀</span></a></li>
</ul>
</div>-->
<!-- Menu --><!--
<div class="dropdown">
<button class="btn2 btn-primary dropdown-toggle position-sticky" type="button" data-toggle="dropdown"><span class="glyphicon glyphicon-menu-hamburger"></span></button>
<ul class="dropdown-menu">
<li><a href=".\Home.php">Homepage</a></li>
<li class="dropdown-header">Sezione Ristorazione</li>
<li><a href="Menu.php"> Menù </a></li>
<li class="divider"></li>
<li class="dropdown-header">Sezione Utente</li>
<?php
//Controllo se utente è loggato
/*
if(isset($_SESSION['user_ID']))
{
echo "<li><a href='./Profilo.php'><span class='glyphicon glyphicon-user'></span> Modifica Password</a></li>";
echo "<li><a href='../PHP/logout.inc.php'><span class='glyphicon glyphicon-log-out'></span> Log Out</a></li>";
}
else
{
echo "<li><a href='./registrazione.php'> Registrazione</a></li>";
echo "<li><a href='./Login.php'><span class='glyphicon glyphicon-log-in'></span> Log In</a></li>";
}*/
?>
</ul>
</div>
-->
<!--Logo del sito cliccabile -->
<ul class="ultenda">
<div style="float: center;">
<center>
<a href="Home.php"><img class="logoimg" src="..\Resources\Images\logo.png" alt="logo! :)"/></a>
</center>
</div>
</ul>
<style>
#login_bar{
width:300px;
position:fixed;
z-index: 10;
border:1px solid black;
top:-5px;
right:0px;
}
#header{
width:1000px;
background-image:url('../images/hf1.jpg');
background-size: 100%;
background-repeat: no-repeat;
position: relative;
border-radius:5px;
min-height: 100px;
}
#login_signup{
float:right;
}
#login_signup > li{
float:left;
padding-right: 30px;
list-style: none;
line-height:25px;
padding-top:6px;
display:inline-block;
}
#login_signup li > a{
font-family:sans-serif;
font-size: 17px;
font-weight: bold;
color:white;
padding:5px;
display:inlineblock;
background-color:black;
border-radius:5px;
-moz-border-radius:5px;
-webkit-border-radius: 5px;
-o-border-radius:5px;
box-shadow: rgb(0,0,0) 0px 0px 10px;
-moz-box-shadow: rgb(0,0,0) 0px 0px 10px;
-webkit-box-shadow: rgb(0,0,0) 0px 0px 10px;
-o-box-shadow:rgb(0,0,0) 0px 0px 10px;
}
#login_signup li span{
font-size: 12px;
display:inlineblock;
}
#login_signup li a:hover{
cursor: pointer;
box-shadow: rgb(255,255,255) 0px 0px 5px;
-moz-box-shadow: rgb(255,255,255) 0px 0px 5px;
-webkit-box-shadow: rgb(255,255,255) 0px 0px 5px;
-o-box-shadow:rgb(255,255,255) 0px 0px 5px;
border-radius: 2px;
background-color: white;
color:#006666;
}
</style>
<!-- Piè di pagina/Varie info -->
<ul class="ultenda1">
<div style="float: center;">
<p style="color:red;" align="center">INFO</p>
</div>
</ul>
</body>
</html>
function addOrdine(){
Test
}