- Joined
- May 28, 2016
- Posts
- 825
- Solutions
- 1
- Reaction
- 142
- Points
- 298
Good day po! Baka alam niyo po kung paano i-show yung prutas base sa quantity na ilalagay? Say for example i-select ko yung apple then maglalagay ako ng quantity, then magpapakita yung picture ng apple, and kapag i increase po yung value, dumadami po yung picture nung apple same as kapag idecrease ko, mababwasan din.
Ito po yung code ko po, di ko po kasi makuha yung logic po, hehe. Salamat po sa tutulong !!
Ito po yung code ko po, di ko po kasi makuha yung logic po, hehe. Salamat po sa tutulong !!
JavaScript:
<!DOCTYPE html>
<html>
<head>
<title></title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/js/bootstrap.bundle.min.js" integrity="sha384-MrcW6ZMFYlzcLA8Nl+NtUVF0sA7MsXsP1UyJoMp4YLEuNSfAP+JcXn/tWtIaxVXM" crossorigin="anonymous"></script>
</head>
<body>
<header class="container p-3 alert-danger">
<h3>Fruit Booth</h3>
<p>Shows fruits depending on quantity</p>
</header>
<section class="container my-3">
<h4>Welcome to Fruit Booth</h4>
<hr>
<div class="form-group" style="width: 100%;">
<label for="fruit">Fruit</label>
<select id="select" class="form-select">
<option>Select Fruit</option>
</select>
<br>
<label for="quan">Quantity</label>
<input type="number" id="quantity" placeholder="" class="form-control" onclick="">
<br><label for="code">Result:</label>
<h3 id="code"></h3>
</div>
</section>
<script type="text/javascript">
var select = document.getElementById("select"),
arr = [];
arr[0] = 'Apple';
arr[1] = 'Banana';
for(var i = 0; i<arr.length;i++){
var option = document.createElement("option"),
txt=document.createTextNode(arr[i]);
option.appendChild(txt);
option.setAttribute("value",arr[i]);
select.insertBefore(option,select.lastChild);
}
function quan(){
var a = document.getElementById("select")
}
</script>
</body>
</html>