Dynamic Button call JavaScript Function
<p>I have a script and a Dinamic created Button and event OnClick doesn't work
I need to pass Id and inQuantidade to ValidarEstoqueVenda.htm and JavaScript is the only way i think its possible </p>

<pre><code>page import="usuario.usuario"%&gt;
&lt;%@page import="DAO.DAO"%&gt;
&lt;%@page import="java.util.ArrayList"%&gt;
&lt;%@page import="produto.produto"%&gt;
&lt;%@page import="java.util.List"%&gt;
&lt;%@page contentType="text/html" pageEncoding="UTF-8"%&gt;
&lt;% usuario Usuario = (usuario) session.getAttribute("Usuario");%&gt;
        &lt;script&gt;
            function clickVender(){
                var Id = document.getElementById('Id');
                var inQuantidade = document.getElementById('inQuantidade');
                if(Id.value != "")
        alert("You entered: " + Id.value)
                 else
        alert("Would you please enter some text?")
                document.location.href="ValidarEstoqueVenda.htm?Id="+Id.value+"&amp;inQuantidade="+inQuantidade;
            }
        &lt;/script&gt;
&lt;!DOCTYPE html&gt;
&lt;html&gt;
    &lt;head&gt;
        &lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8"&gt;
        &lt;link rel="stylesheet" href="css/materialize.css"&gt;
&lt;!-- Include CSS File Here --&gt;
        &lt;script src="js/materialize.js"&gt;&lt;/script&gt;
        &lt;title&gt;Estoque Online - Estoque&lt;/title&gt;
    &lt;/head&gt;
    &lt;body&gt;
     &lt;div class="navbar-fixed"&gt;
    &lt;nav id="nav_f" class="default_color" role="navigation"&gt;
        &lt;div class="container"&gt;
            &lt;div class="nav-wrapper"&gt;
            &lt;a href="#" id="logo-container" class="brand-logo"&gt;Controle de Estoque&lt;/a&gt;
                &lt;ul class="right hide-on-med-and-down"&gt;
                &lt;li&gt;&lt;a href="Estoque.jsp"&gt;Estoque&lt;/a&gt;&lt;/li&gt;
                &lt;%if (Usuario.getTipo() == 2){%&gt;
                &lt;li&gt;&lt;a href="CadastroEstoque.jsp"&gt;CadastroEstoque&lt;/a&gt;&lt;/li&gt;
                &lt;li&gt;&lt;a href="CadastroTipo.jsp"&gt;Cadastro Tipo&lt;/a&gt;&lt;/li&gt;
                &lt;li&gt;&lt;a href="Tipo.jsp"&gt;Tipo&lt;/a&gt;&lt;/li&gt;
                &lt;li&gt;&lt;a href="Usuario.jsp"&gt;Usuario&lt;/a&gt;&lt;/li&gt;
                &lt;%}%&gt;
                &lt;li&gt;&lt;a href="redirect.jsp"&gt;Sair&lt;/a&gt;&lt;/li&gt;
                &lt;/ul&gt;
                &lt;ul id="nav-mobile" class="side-nav"&gt;
                &lt;li&gt;&lt;a href="Estoque.jsp"&gt;Estoque&lt;/a&gt;&lt;/li&gt;
                &lt;%if (Usuario.getTipo() == 2){%&gt;
                &lt;li&gt;&lt;a href="CadastroTipo.jsp"&gt;Cadastro Tipo&lt;/a&gt;&lt;/li&gt;
                &lt;ul id='dropdown2' class='dropdown-content'&gt;
                &lt;li&gt;&lt;a href="Usuario.jsp"&gt;Usuario&lt;/a&gt;&lt;/li&gt;
                &lt;/ul&gt;
                &lt;%}%&gt;
                &lt;li&gt;&lt;a href="redirect.jsp"&gt;Sair&lt;/a&gt;&lt;/li&gt;
                &lt;/ul&gt;
            &lt;a href="#" data-activates="nav-mobile" class="button-collapse"&gt;&lt;i class="mdi-navigation-menu"&gt;&lt;/i&gt;&lt;/a&gt;
            &lt;/div&gt;
        &lt;/div&gt;
    &lt;/nav&gt;
   &lt;/div&gt;
        &lt;form action="ValidarEstoque" method="get"&gt;
            &lt;table class="striped responsive-table black-text teal darken-1"&gt;
                &lt;thead&gt;
                    &lt;tr&gt;
                        &lt;th data-field="id"&gt;Id&lt;/th&gt;
                        &lt;th data-field="nome"&gt;Descricao&lt;/th&gt;
                        &lt;th data-field="email"&gt;Quantidade&lt;/th&gt;
                        &lt;th data-field="Alterar"&gt;Alterar&lt;/th&gt;
                        &lt;th data-field="Excluir"&gt;Exlcuir&lt;/th&gt;
                    &lt;/tr&gt;
                &lt;/thead&gt;
                    &lt;tbody&gt;
                        &lt;tr&gt;
                            &lt;%  List&lt;produto&gt; produtos = new ArrayList&lt;produto&gt;();
                            DAO dao = new DAO();
                            produtos = dao.listarEstoque();%&gt;                         
                            &lt;%for(produto produto : produtos){%&gt;
                            &lt;td&gt;&lt;%=produto.getId()%&gt;&lt;/td&gt;
                            &lt;td&gt;&lt;%=produto.getDescricao()%&gt;&lt;/td&gt; 
                            &lt;td&gt;&lt;input type="text" id="inQuantidade" name="inQuantidade" value="&lt;%=produto.getQuantidade()%&gt;"&gt;&lt;/td&gt;
                            &lt;% if(Usuario.getId() != 0){%&gt;
                            &lt;td&gt;&lt;a href="CadastroEstoque.jsp?Id=&lt;%=produto.getId()%&gt;"&gt;Alterar&lt;/a&gt;&lt;/td&gt;
                            &lt;td&gt;&lt;a href="Excluir.htm?Id=&lt;%=produto.getId()%&gt;&amp;exclusao=Estoque"&gt;Excluir&lt;/a&gt;&lt;/td&gt;
                            &lt;td&gt;&lt;a class="btn waves-effect waves-light col s12" onclick="clickVender()"&gt;Vender&lt;/a&gt;&lt;/td&gt;
                            &lt;%
                            }
                            %&gt;
                        &lt;/tr&gt;
                        &lt;%
                        }
                        %&gt;             
                    &lt;/tbody&gt;
            &lt;/table&gt;                                       
        &lt;/form&gt;
    &lt;/body&gt;
&lt;/html&gt;
</code></pre>

<p>The last tag  have the onCLick function.</p>

<p>Please Help me</p>