Jquery showing list

Asked

Viewed 78 times

1

How do I keep the populated values fixed? each time I change the fields it changes simultaneously.

And another, how do I present the values separately? I ended up concatenating only to show the values :P

thanks!


load_info.js

$(document).click(function capturar()
    {
        var c1 = document.getElementById("criterio").options[document.getElementById("criterio").selectedIndex].text
        var c2 = document.getElementById("gravidade").options[document.getElementById("gravidade").selectedIndex].text
        var c3 = document.getElementById("obs").value;

        document.getElementById("resultado").innerHTML = c1+c2+c3;

    });

html test.

</head>
    <body>
      <form id="iniciar">
          <form>
          <fieldset>
          <legend><span class="number">1</span> blablabla</legend>
            <label for="crit">Selecione o critério:</label>
            <select id="criterio" name="field4">
            <optgroup label="opçoes">
              <option value="crit1">1</option>
              <option value="crit2">2</option>
            </optgroup>
            </select>

            <label for="grav">Gravidade:</label>
            <select id="gravidade" name="field4">
            <optgroup label="selecionee">
              <option value="crit1">1</option>
              <option value="crit2">2</option>
            </optgroup>
            </select>

            <legend> Observação / Solução </legend>
            <textarea id="obs" name="field3" placeholder="adicione algum 
            comentario">
            </textarea>
            </fieldset>

            <input id="res1" class="res" type="button" 
            onload="capturar('carrega_info')" value="Adicionar marcador na 
            página">

            <ul><li id="resultado"> Erros encontrados:</li></ul>
    </body>
</html>
  • something like that? https://jsfiddle.net/9wv9bwtb/

  • exactly! Thank you @Gabrielrodrigues

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.