<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
<script src="https://code.jquery.com/jquery-3.1.0.js"></script>
</head>
<body>
<div id="card_1" class="box-container">
<section class=box-image>
<img src="" style="border-radius:10px" width="250px" height="230px"/>
</section>
<section class="box-content">
<label class="title">
<div align="left"><b>A MODA DA CASA</b></div>
</label>
<span class="description">
<div align="left">Molho de tomate, mussarela, calabresa ralada, catupiry, alho tostado, cebola, azeitonas e oregano</div>
</span>
</section>
<section class=box-image-2>
<label class="title">
<div align="center"><b class="currency-value-displayed">28,00</b></div>
</label>
<span class="description">
<div align="left"><br/>
<input type="checkbox" name="sabor" id="evento_value" class="currency-check" value="28,00">
<input type="hidden" name="vl_sabor" class="total-value"value="28,00">
<SELECT name="qntdade" onchange="changedValue(event, 'card_1')">
<option value="1">1</option>
<option value="2">2</option>
</SELECT>
</div></span>
</section>
</div>
<div id="card_2" class="box-container">
<section class=box-image>
<img src="" style="border-radius:10px" width="250px" height="230px"/>
</section>
<section class="box-content">
<label class="title">
<div align="left"><b>A MODA DA CASA 2</b></div>
</label>
<span class="description">
<div align="left">Molho de tomate, mussarela, calabresa ralada, catupiry, alho tostado, cebola, azeitonas e oregano</div>
</span>
</section>
<section class=box-image-2>
<label class="title">
<div align="center"><b class="currency-value-displayed">25,00</b></div>
</label>
<span class="description">
<div align="left"><br/>
<input type="checkbox" name="sabor" id="evento_value" class="currency-check" value="25,00">
<input type="hidden" name="vl_sabor" class="total-value"value="25,00">
<SELECT name="qntdade" onchange="changedValue(event, 'card_2')">
<option value="1">1</option>
<option value="2">2</option>
</SELECT>
</div></span>
</section>
</div>
</body>
</html>
body {
width: 450px
}
.box-image-2 {
display: flex;
align-items: center;
}
.banner img {
max-width: 100% !important;
height: 200px;
}
.container-cards {
flex-wrap: wrap;
display: inline-flex;
width: 400px;
align-items: center;
justify-content: center;
}
.box-container {
/*border: 1px solid red;*/
display: flex;
background: #fcfcfc;
font:80%/1 Arial;
font-size: 14px;
border-radius: 5px;
align-items: center;
width: 100%;
height: 80px;
border: 0px solid #AAAAAA;
margin: 5px;
background-color: #fcfcfc;
box-shadow: 1px 3px 5px rgba(250, 242, 242, 0.77);
box-shadow: 1px 3px 5px rgba(250, 242, 242, 0.77);
box-shadow: 1px 3px 5px rgba(250, 242, 242, 0.77);
}
.box-image {
width: 20%;
align-items: center;
display: flex;
height: 100%;
justify-content: left;
border-right: 0px solid #AAAAAA;
}
.box-container .box-image img {
width: 75px;
height: 75px;
}
.box-container .box-content {
align-items: left;
display: flex;
height: 75%;
justify-content: left;
flex-direction: column;
padding: 10px;
}
.title {
margin-bottom: 10px;
font-size: 16px
font-weight: bold;
color: #000;
}
.description {
font:80%/1 Arial;
font-size: 14px;
color: #8a8686;
top: 50px;
left: 50px;
}
function changedValue(event, id) {
var atualValue = $('#'+id+' .currency-check').val();
var quantity = event.currentTarget.value;
var newValue = calcValue(quantity, atualValue);
console.log(newValue, quantity, atualValue, id);
updateCardValue(id, newValue)
}
function updateCardValue(cardId, newValue) {
// $('#'+cardId+' #evento_value').val(newValue);
$('#'+cardId+' .currency-value-displayed').text(formatPrice(newValue, false));
$('#'+cardId+' .total-value').val(newValue);
}
function calcValue(quantity, price) {
return parseInt(quantity) * parseFloat(price);
}
function formatPrice(value, currency = true) {
var valor = parseFloat(value);
let valorFormatado = null;
if(currency) {
//Valor com cifrão
valorFormatado = valor.toLocaleString('pt-BR', { style: 'currency', currency: 'BRL' });
}
else {
//Valor sem cifrão
valorFormatado = valor.toLocaleString('pt-BR', { minimumFractionDigits: 2});
}
return valorFormatado;
}
Output
300px
You can jump to the latest bin by adding /latest
to your URL
Keyboard Shortcuts
Shortcut | Action |
---|---|
ctrl + [num] | Toggle nth panel |
ctrl + 0 | Close focused panel |
ctrl + enter | Re-render output. If console visible: run JS in console |
Ctrl + l | Clear the console |
ctrl + / | Toggle comment on selected lines |
ctrl + ] | Indents selected lines |
ctrl + [ | Unindents selected lines |
tab | Code complete & Emmet expand |
ctrl + shift + L | Beautify code in active panel |
ctrl + s | Save & lock current Bin from further changes |
ctrl + shift + s | Open the share options |
ctrl + y | Archive Bin |
Complete list of JS Bin shortcuts |
JS Bin URLs
URL | Action |
---|---|
/ | Show the full rendered output. This content will update in real time as it's updated from the /edit url. |
/edit | Edit the current bin |
/watch | Follow a Code Casting session |
/embed | Create an embeddable version of the bin |
/latest | Load the very latest bin (/latest goes in place of the revision) |
/[username]/last | View the last edited bin for this user |
/[username]/last/edit | Edit the last edited bin for this user |
/[username]/last/watch | Follow the Code Casting session for the latest bin for this user |
/quiet | Remove analytics and edit button from rendered output |
.js | Load only the JavaScript for a bin |
.css | Load only the CSS for a bin |
Except for username prefixed urls, the url may start with http://jsbin.com/abc and the url fragments can be added to the url to view it differently. |