-1
I’m making a restaurant management system , but I kind of want the select to be dynamic , type not always the customer wants a food only , so I wanted to know how I can do to go adding every time I click on more. this system only works on the site, only I want to use it only on the localhost and it doesn’t work.
<html>
<head>
<body>
<h1>Peixaria</h1>
<ul class="menu cf">
<li><a href="secao.php">Início</a></li>
<li><a href="pedidos.php">Pedidos</a></li>
<li><a href="reserva.php">Reserva</a></li>
<li><a href="relatorio.php">Relatório</a></li>
</ul>
<main>
<form>
<header>
<h2>Fazer Pedido</h2>
</header>
<fieldset>
<label>
<span>Comanda:</span>
<input type="text" value="" autofocus>
</label>
<label>
<span>Mesa:</span>
<input type="text" value="" autofocus>
</label>
<span>Refeições/Bebidas/Sobremesas:</span>
<label>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<select id="selecionar">
<option selected isabled>Selecione</option>
<option >Costela de Tambaqui sem Espinha</option>
<option selected>Lombo de Tambaqui Frito sem Espinha</option>
<option >Caldeirada de Tambaqui sem Espinha</option>
<option >Caldeirada de Tucunaré</option>
<option selected>Peixe no Tucupi com Camarão</option>
<option >Escabeche de Pirarucu</option>
<option >Escabeche de Tambaqui</option>
<option >Escabeche de Tucunaré</option>
<option >Tucunaré Frito</option>
<option selected>Sardinha Frita</option>
<option >Jaraqui Frito</option>
<option >Pacu Frito</option>
<option selected>Filé de Pirarucu Frito</option>
<option >Filé de Pirarucu a Milanesa</option>
<option >Guisado de Pirarucu</option>
</select>
<a class="add" href="#">+</a>
<hr>
Selecionados
<hr>
<div id="selecionados">
</div>
</label>
<label>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<select id="selecionar">
<option selected isabled>Selecione</option>
<option >Fanta Laranja 1l</option>
<option >Fanta Laranja 2l</option>
<option selected>Cola Cola 1l</option>
<option >Cola Cola 2l</option>
<option >Bare 2l</option>
<option selected>Fanta Uva</option>
<option >Fanta Laranja</option>
<option >Sprit</option>
<option selected>Cola Cola </option>
<option >Cola Cola zero </option>
<option >Guaraná Antarctica</option>
<option selected>Guaraná Baré</option>
<option >Suco Goiaba</option>
<option selected>Suco Manga</option>
<option >Suco Pessego</option>
<option >Suco Uva</option>
<option selected>Suco Maracujá</option>
<option >Suco Laranja</option>
<option >Suco Caju</option>
<option selected>Agua Mineral </option>
<option >Agua com Gas </option>
<option >Cerveja em Lata</option>
<option selected>Limonada Natural</option>
</select>
<a class="add" href="#">+</a>
<hr>
Selecionados
<hr>
<div id="selecionados">
</div>
</label>
</fieldset>
</form>
</main>
<script>
$(".add").on('click',function(){
var cont=0;
$("#selecionados input").each(function(){
if($(this).val()==$("#selecionar option:selected").html()){
cont++;
}
});
if(cont>0){ alert("Este item ja esta adicionado, altere a quantidade se deseja mais..");}
else{
$("#selecionados").append("<input disabled type='text' name='pedidos[]' value='"+$("#selecionar option:selected").html()+"' ><input type='text' name='quantidade[]' placeholder='quantidade'><br>");
}
});
</script>
</body>
</head>
</html>
Have you ever thought of using a
<select multiple>
? http://www.w3schools.com/TAgs/att_select_multiple.asp– Leonardo Rodrigues
Look at the browser console, see if it points out any errors, because it should run on localhost
– LocalHost
Good afternoon. A hint: you are tagging
<script>
outside the<html>
(may be why it is being ignored). The best place for tag<script>
is usually at the end of the<body>
, which, by the way, you don’t have. I suggest better structuring your html with the correct tags<html><head></head><body></body></html>
. Finally, I put your code in a fiddle and it seems to be working: https://jsfiddle.net/mrlew/8e9xLure/ .– mrlew
already put , still does not work on localhost . the code is as I edited above
– allan araujo
Remove css from the last line
.add{ text-decoration:none;}
that, and adds to the tag<style>.add{ text-decoration:none;}</style>
– LocalHost
I’ve already done it put it in style where I get the coccid css , but in localhost it doesn’t take . but when I try it online it works .
– allan araujo
look at the browser console, see if it points any error
– LocalHost
yes in border-Sizing: border-box; a warning sign appears .
– allan araujo
@allanaraujo continues to have syntax problems. You have not closed the
<head>
nor the<html>
. And tag<style>
inside head. Checked console for errors? you have a local server or are opening in the file?– mrlew
Well now it’s working , but it’s overlapping one over the other and the part of the drink only give to select one when I go select another it give that has already been added . doesn’t look like it does on site , I put a print above how it looks
– allan araujo