Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

286
Visualizações
How to search through an object and return a value that can be appended to HTML?

I'm trying to make an art quote calculator and am having trouble with the following code. I want the calculateQuote function to traverse through the costs object using the value of different select elements in order to find the right price and then display that price. However, I'm running into an error somewhere in the submit.onclick portion I believe. When I run the code, at that step, nothing gets populated onto the page.

const costs = {
        "painting": {
            "simple": {
                "_10x10": "25", 
                "_11x14": "55", 
                "_16x20": "75", 
                "_18x24": "100"},
            "complex": {
                "_10x10": "55", 
                "_11x14": "75", 
                "_16x20": "100", 
                "_18x24": "150-250"}
        },
    
        "pencil": {
            "simple": {
                "_11x14": "150"},
            "complex": {
                "_11x14": "150"}
        },
    
        "mural": {
            "simple": {
                "_3x5": "200-300", 
                "_8x12": "750", 
                "_10x12": "950", 
                "_8x24": "1,500"},
            "complex": {
                "_3x5": "500", 
                "_8x12": "1,150", 
                "_10x12": "1,400", 
                "_8x24": "2,300"}
        }
    }
    
    
        function calculateQuote(){
          if(typeElement.value === "painting"){
            const finalquote = costs.typeValue.complexityValue.paintingSizeValue;
          } else if(typeElement.value === "pencil"){
            const finalquote = costs.typeValue.complexityValue.pencilSizeValue;
          } else {
            const finalquote = costs.typeValue.complexityValue.muralSizeValue;
          }
          return finalquote;
        }
    
        submit.onclick = function(){
          hideDiv(complexityElement);
          hideDiv(complexityLabelElement);
          hideDiv(submit);
          let clientQuote = document.createElement('p');
          clientQuote.innerHTML = calculateQuote();
          quoteDiv.appendChild(clientQuote);
          quoteDiv.style.display = "block";
        }
about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda