javascript - Displaying multiple objects one at a time in a dialog box -
i stuck. trying display objects individually in pop-up dialog box, , can't find information how this. can display them @ once, not trying do.
$.each(needs, function(i, v) { console.info(v); var brand = v.brand; console.info(brand); var model = v.model; var growerid = v.growerid; if (v.portalid === null) { var unmatched = { brand: v.brand, model: v.model, growerid: v.growerid } newmatch.push(unmatched); console.info(newmatch); } else { return false; } });
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <div class="wrap"> <form> <div class="fleft"> <div> <img src="/app/public/css/images/logo.png"> </div> <div class="form-group brand ui-corner-all"> <label for="owner">brand</label> <div class="card-type ui-corner-all " id="brand"></div> </div> <div class="form-group ui-corner-all"> <label for="model">model</label> <div class="model ui-corner-all " id="trxio_model"></div> </div> <div class="form-group growerid"> <label for="growerid">grower id</label> <div class="card-type ui-corner-all " id="growerid"></div> </div> <div class="form-group vendor ui-corner-all "> <label for="owner">default vendor</label> <div class="card-type ui-corner-all " id="vendor"></div> </div> <button type="submit" class="btn btn-lg">update product info</button> </div> </form> </div>
any appreciated. thanks.
because provided partial code doesn't work i've written little example how iterate on collection of cars , how render them html container. lead solution:
var cars = [ { name: "vw", year: 1988, }, { name: "honda", year: 1999, }, { name: "bmw", year: 2005, } ] const container = document.queryselector('#container') const torender = cars.map(car => `<div class="car"><span class="name">${car.name}</span> <span class="year">${car.year}</span></div>`) container.innerhtml = torender.join('')
.container { padding: 10; background: #f0f0f0; } .car { margin: 10px 0; } .name { display: inline-block; padding: 5px; color: #ff0000; min-width: 100px; } .year { color: blue; }
<div id="container"></div>
wiki
Comments
Post a Comment