0

Sorry for the silly question. I have a div container "product-card" , I want to loop the number of my deployed smart contracts time. every time when I loop I want to clone this div container and insert contract details(every time different data based on contract details). how can I achieve it?, I tried clone(). but it keeps cloning same data to all cloned divs

here is html

<div class="product-card" id="copy">
    <div class="badge">Hot</div>
    <div class="product-tumb" id="coverImage">
    </div>
    <div class="product-details" id="bookId">
        <span  id="table" class="product-catagory"></span>
        <h4><a href="" id="bookName"></a></h4>
        <p id="description">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Vero, possimus nostrum!</p>
        <div class="product-bottom-details">
            <div class="product-price" id="price"><small id="price"></small>$230.99</div>
            <div class="product-links">
                <a href=""><i class="fa fa-heart"></i></a>
                <a href=""><i class="fa fa-shopping-cart"></i></a>
            </div>
        </div>
    </div>
</div>

here is my js file

StartTrade.getContractcount(function(error, result){
                  if(!error){
                      console.log(result);
                      console.log(JSON.stringify(result));
                      var contractCount = Number(result);
                      var t = $("#contractTable").val();




                      for (var i = 0; i<contractCount; i++){

                      StartTrade.contracts(i,function(error, result){
                        if(!error){
                        //  console.log("cont addr ["+[result]+"]");
                          console.log(result);
                            document.getElementById("table").innerHTML = result;
                            var Purchase = PurchaseContract.at(result);
                            Purchase.price(function(error, result) {
                              if(!error){
                                console.log(JSON.stringify(result));
                                $('#price').html("price eth: "+result/1000000000000000000);
                                      }
                                      else {
                                console.log(error);
                                          }
                            })
                            Purchase.name(function(error, result) {
                              if(!error){
                                console.log(JSON.stringify(result));
                                $('#bookName').html(result);
                                  }
                                  else {
                                console.log(error);
                                }
                            })
                            Purchase.text(function(error, result){
                              if(!error){
                                console.log(JSON.stringify(result));
                                $('#description').html(result)
                                      }
                                      else {
                                        console.log(error);
                                            }
                            })
                          Purchase.cover(function(error, result) {
                            if(!error) {
                              console.log(JSON.stringify(result));
                              $("#coverImage").html("<img src=http://localhost:8080/ipfs/" + result + ">");
                                      }
                          })

                        }
                          else{
                              console.error(error);
                              }
                          });
                        }
                      }
                      else{
                        console.error(error);
                      }

                });

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.