Given of the variable identSuited in the URL. How to resolve?

Asked

Viewed 34 times

0

Equipment

      <!-- redireciona os dados para atualizar levando o ID do equipamento  e identificação do usuário a ser redirecionado-->

     <script type="text/javascript">
        function reservar(){
        var identUsuario = identUsuario;
        var formReserva = document.forms[0];
        formReserva.action="MainServlet?acao=reservaEquipamento&idequipamento=${param.idequipamento}&identUsuario=${param.identUsuario}";  // Dado identUsuario vem em branco na URL
        formReserva.submit();

    }
    </script>
</head>
<body>

  <div class="container">
    <div class="caixa-topo">
      <h1>SGCI</h1>
      <p> SISTEMA PARA GERENCIAMENTO COORDENAÇÃO DE INFORMÁTICA</p>
    </div>
  </div>

  <div class="bara-topo u-full-width">
    <div class="container">
      <div class="topo">
        <span class="itens">ADMINISTRADOR</span>
        <span class="flaticon-power27 itens u-pull-right"></span>
        <span class="flaticon-info27 itens u-pull-right"></span>
      </div>
    </div>
  </div>
  <div class="container">
    <div class="twelve columns">
      <div class="row">
        <div class="equipamentos">
          <div class="four columns">
            <div class="menu-equipamento">
              <p>
                  <a href="equipamento.jsp"><img src="icones/eqp.png"></a><br><label>Reserva Equipamentos</label>
              <p>
              <hr width="50%">
              <a href="cadastraEquipamento.jsp"><img src="icones/adceqp.png">Cadastrar<br></a>
              <a href="MainServlet?acao=consultarEquipamento"><img src="icones/edteqp.png" alt="Editar">Alterar/Remover<br></a>
              <a href="MainServlet?acao=consultarReservaEquipamento"><img src="icones/rsveqp.png"></span>Reservar<br></a>
            </div>
          </div>
            <div class="eight columns">
              <p class="u-pull-left">Informações do equipamento:</p> 



            <!-- dados do equipamentos a ser reservado-->                                  
              <table>
              <tr><td class="hidden">${param.idequipamento}</td></tr>
              <tr><td>Nome:</td><td> ${param.nome}</td></tr>
              <tr><td>Marca:</td><td> ${param.marca}</td></tr>
              <tr><td>Código:</td><td> ${param.codigo}</td></tr>
              </table>

              <form method="post" id="consultaEquipamentos" action="#">
              <span>Número de identificação do usuário:</span><br/> 
              <input type="text" name="identUsuario">
              <input type="button" onClick="reservar()">
              </form>

            </div>
        </div>
      </div>
    </div>
  </div>
  <footer class="rodape">
    <p>Tecno System Empresa Júnior - UNEB, todos os direitos reservados.</p>
  </footer>
</body>

  • the Identusuario that is being assigned to you from where?

  • Hi! It’s coming from the <input type="text" name="identUsuario">

  • There is not enough information in the question. These expressions ${...} do not exist in HTML, you must be using a language that builds to HTML or a language next to the server, but doesn’t even mention it in the question. If "${param.identUsuario}" is a type of string, so be sure to cover it with `, or " and remember to use DOM methods to get elements.

  • I’m using JSP. And this "${param.idequipamento}" is Expression language (EL) that allows you to access stored data and bring p interface.

1 answer

0


You have to take the input value that the user type , and no longer assign the field name, try so:

Add an identifier in the field you want:

<input type="text" name="identUsuario" id="ident_user">

Takes its value via javascript and assigns it to the variable:

var identUsuario = document.querySelector("#ident_user").value;

Then do what you want with it.

  • So, I had already tried with Document.getElementById and even so is passing the data T-T If you have other ideas, please share, please.

  • Probably because you are calling the script to capture the element before it is rendered on the screen, move your scripts to before the end of the body , so the screen is rendered with its elements and with that javascript can capture them.

  • Sorry to keep you waiting. It does not solve the problem, the script is only triggered when clicked on the button in the form, so the data will already be rendered, so much so that the other data is passing, except for identUsuario. But thank you.

  • You said you were using get.. Byid() and there was no id in the element, in mine, I added an id only to capture it. You tried using id?

Browser other questions tagged

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