Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>JS Bin</title>
</head>
<body>
  <table>
      <th>ptt</th>
      <tr>
          <td id="ptt">10</td>
      </tr>
  </table>
   
  <hr>
    
    <select id="select">
    <option value="0">Escolha o valor</option>
    </select>
  
</body>
</html>
 
table, th, tr, td {
    border: 1px solid #CCC;
}
#select {
    display: none;
}
 
let arrVal = [3, 5, 7, 10, 13, 15, 17],
    ptt = parseFloat(document.querySelector("#ptt").innerHTML),
    newArr = null
    arrVal.map( (cv, i, arr) => {
      
      if(cv == ptt){
        
        newArr = arr.slice(0, i+1)
        
        for(let i = 0; i < newArr.length; ++i) {
          let option = document.createElement("option");
          option.text = `R$ ${newArr[i].toFixed(2)}`
          option.value = newArr[i]
          let select = document.querySelector("#select")
          select.appendChild(option)
          select.style.display = 'block'
         
        }
      
      }
      
    })
    
 
    
    
Output 300px

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
angelorubinpro
0viewers