Doubt which variable to pass from my Select

Asked

Viewed 87 times

-1

I have two selects, both consult the database. I have Equipment, and Operations...

Selects

When selecting equipment x in select, I will consult the database for the select Operations to pull only Operations that are not in use according to the equipment I selected.

Where this "variable" in the operation query, is that I must pass what was selected in select equipments, to show only the available operations according to what I selected in the select of equipments.

but I don’t know what I should spend there as a select variable.

MY EQUIPMENT SELECT

<select name='field-number-key-COD_EQUIP' id='field-number-key-COD_EQUIP' type='text' class='form-control input-lg'lang='Equipamento,N'
onkeypress='Javascript:return only_alphabetic_acentos(this,event);' disabled >
<option value='' selected>-- Selecione --</option>
<struts_logic:iterate id="arrHH_EQUIPAMENTOS" name="collHH_EQUIPAMENTOS" scope="page" type="java.util.ArrayList">
<option value='<%=arrHH_EQUIPAMENTOS.get(0).toString()%>'
<%=arrHH_EQUIPAMENTOS.get(0).toString().equals(COD_EQUIP) ? "selected" : ""%> >
<%=arrHH_EQUIPAMENTOS.get(1).toString()%>
</option>
</struts_logic:iterate>
</select>

MY OPERATION SELECT

<select name='field-number-key-CODOPERACAO' id='field-number-key-CODOPERACAO' type='text' class='form-control input-lg' lang='Operação,N' onkeypress='Javascript:return only_alphabetic_acentos(this,event);' disabled >
<option value='' selected>-- Selecione --</option>
<struts_logic:iterate id="arrHH_OPER_CAMPO" name="collHH_OPER_CAMPO" scope="page" type="java.util.ArrayList">
<option value='<%=arrHH_OPER_CAMPO.get(0).toString()%>'
<%=arrHH_OPER_CAMPO.get(0).toString().equals(CODOPERACAO) ? "selected" : ""%> >
<%=arrHH_OPER_CAMPO.get(1).toString()%>
</option>
</struts_logic:iterate>
</select>

CONSULTATION AT THE EQUIPMENT BANK

<executequery:query resultSet="collHH_EQUIPAMENTOS" listPages="collListPagesHH_EQUIPAMENTOS"
sqlSelect="select s.codequip, s.descrequip from hh_equipamentos s where s.action<>'D' order by s.descrequip" page="0" conPool="4" >
</executequery:query>

CONSULTATION AT THE BANK FOR OPERATION

<executequery:query resultSet="collHH_OPER_CAMPO" listPages="collListPagesHH_OPER_CAMPO"
sqlSelect="SELECT CODOPERCAMPO, DESCROPERCAMPO FROM hh_oper_campo O
WHERE O.CODOPERCAMPO NOT IN (SELECT CODOPERACAO FROM MED_EQUIP M WHERE m.COD_EQUIP = <variavel>); " page="0" conPool="4" >
</executequery:query>
  • Your m.COD_EQUIP must receive the value <option value='<%=arrHH_EQUIPAMENTOS.get(0).toString()%>' because it seems to me that this is where the code is defined. You would have to call the value of this input by the id/name. I recommend avoiding scriptlets in your code. This was used almost 20 years ago. Read at least about jstl.

  • Problem is that it is an old system I just make some changes, but as there is nothing documented and is also well outdated several things, I’m having enough difficulty in some things, I thank I will test the way you passed !

  • @rhenesys this struts_logic:iterate that has the id/name is where is storing the value of options ? sorry for the question I’ve never picked up this structure before

1 answer

0

Your m.COD_EQUIP should receive the value ' because it seems to me that this is where the code is defined. You would have to call the value of this input by the id/name. I recommend avoiding scriptlets in your code. This was used almost 20 years ago. Read at least about jstl.

EDIT:

id="arrHH_EQUIPAMENTOS" name="collHH_EQUIPAMENTOS" calling for the id in javascript you would have the value Selected. Using JSP you would have to call name.

  • not yet given, as I can for example, when I select the select of machines, then makes the operation select... type did not give any error of the jeto that spoke, but it seems that it loads right when I start the page, so as much as I select something in select of machines, the operation select always appears the same things

  • SELECT CODOPERCAMPO, DESCROPERCAMPO FROM hh_oper_campo WHERE CODOPERCAMPO NOT IN (SELECT CODOPERACAO FROM MED_EQUIP M WHERE M.codoperacao = CODOPERCAMPO and M.COD_EQUIP = "+ request.getParameter("collHH_EQUIPAMENTOS")&#xA;&#xA;já tentei com o id também

  • If anyone has any other reasoning how can I do, I accept kkk suggestions

Browser other questions tagged

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