Get the selected value in the combobox with Classic ASP

0

I have two tables in SQL:

A group that has two columns: id and group

A product that has three columns: id, group, and product

In the Products table, the "group" column is equivalent to the "id" column of the groups table.

I'm trying to make an inclusion form into a third table of entries (columns: group, product, and entry).

In this form, there is a combobox in which the user will select the Group and, when selecting the Group, should appear in a second combobox only the Products related to it. (similar to the state / city combobox).

The webpage is connecting right into the database, but I am not able to make the combobox dependent.

I built it as follows:

Combo of two groups:

    <form method="get" action="insert_into.asp" name="formulario">
<% SET RS_grupo = conexao.execute("SELECT * FROM [dbo].[nova_pd_grupos] ORDER BY grupo") %>

                        <div class="row"><div class="col"><p class="p_select">Grupo:</p></div><div class="col">
                            <select class="custom-select custom-select-sm" name="idgrupo">
                                <% while not RS_grupo.eof
                                grupo1= RS_grupo("grupo")
                                idgrupo=RS_grupo("id")
                                grupo=request.querystring("grupo1")
                                %>
                                <% if grupo <>"" then
                                   if grupo = grupo1 then
                                   response.write "<option value="&idgrupo&"&grupo1="&grupo1&" selected>"&grupo1&"</option>"
                                   elseif grupo <> grupo1 then
                                   response.write "<option value="&idgrupo&"&grupo1="&grupo1&">"&grupo1&"</option>"
                                   end if
                                   else 
                                   response.write "<option value="&idgrupo&"&grupo1="&grupo1&">"&grupo1&"</option>"
                                   end if
                                   RS_grupo.movenext
                                   wend
                                   RS_grupo.close
                                %>


                            </select>

                        </div></div>    

Product Combo:

<div class="row"><div class="col"><p class="p_select">Produto:</p></div><div class="col">

                            <select class="custom-select custom-select-sm" name="produto">

<% gruposelected=request.form("idgrupo")

SET RS_produto = conexao.execute("SELECT * FROM [dbo].[nova_pd_produtos] where grupo = "&gruposelected&" order by produto asc;") %>

                            <% while not RS_produto.eof

                                produto1=RS_produto("produto")


                                   response.write "<option value="&produto1&">"&produto1&"</option>"
                                   RS_produto.movenext
                                   wend
                                   RS_produto.close

                                   %>

                                </select>






                        </div></div>

However, nothing appears in the product combo. Can someone help me? How do I make the combobox relate to each other? Classic ASP (vbscript).

Thank you.

    
asked by anonymous 19.06.2018 / 18:34

0 answers