简体   繁体   English

Netbeans根据另一个dropdownlist html netbeans填充下拉列表

[英]Netbeans populating a dropdown list based on another dropdownlist html netbeans

i have an interface where i have two dropdownlists in html,one is mark(marque) of a phone and another is model.so the one of mark works fine(callin data from database(sql)) but i want that each time i choose the dropdown list of model it should not show the whole list of data concerning models from the database but just specific for the marque chosen without refreshin the page.like if i choose the mark Nokia it will automatically show just models of nokia not samsung or any other phone mark! 我有一个接口,其中我在html中有两个下拉列表,一个是手机的mark(marque),另一个是model.so,那个mark可以正常工作(从database(sql)调用数据),但是每次我选择时我都想要在模型的下拉列表中,它不应显示数据库中与模型有关的数据的完整列表,而应仅显示选定的标志,而无需刷新页面。例如,如果我选择标记诺基亚,它将自动仅显示诺基亚的模型而不是三星或任何其他电话标记! i dont know if mayb its sql on model as in the table model i have (model_tel,marque_tel(which is a foreign key from marque_tel)) so i tryed to use the where command for sql but its not workin because i want to say where marquel_tel='//the marque chosen in the marque dropdownist//' but i dnt know how to do that in java (html) 我不知道是否可以像在表模型中那样在模型上使用它的sql(model_tel,marque_tel(这是marque_tel的外键)),所以我试图对SQL使用where命令,但它不起作用,因为我想说哪里marquel_tel ='//在marque dropdownist中选择的marque //',但我不知道如何在Java(html)中做到这一点

the problem is i dont no much about javacsript or ajax.......so if any of u can help it would really mean alot 问题是我对javacsript或ajax的了解不多.......因此,如果您有任何帮助,那真的意味着很多

heres how the example of the code looks like so far(i just wwent straight to the main point here): 到目前为止,这是代码示例的样子(我只是直接转到此处的要点):

<label>Marque:

 <span class="small">selectionner la marque</span></label>

<%ResultSet rst = in.executeQuery("select distinct(Marque_Tel) from Marque_Tel");%> 

<table id="d"><tr><td id="k">
       <select name="marque" id="marque"  onchange="displayDate(this)">
       <% while (rst.next()) {%>
       <option></option>
      <option><%=rst.getString(1)%></option> //showin marksfrom data of sql//
      <% }%>`

   </td></tr></table><br><br><br>
            <label>Modele:
           span class="small">selectionner le modele</span></label>
            //callin phone models from sql database down here//

            <%ResultSet rs = in.executeQuery("select * from Modéle_Tel where           
      marque_tel='"+rst.getString(1).toString()//but this in not workin//"' ");%>

     <select name="modele" id="modele" >
       <% while (rs.next()) {%>
       <option></option>
      <option><%=rs.getString(1)%></option>//callin phones models
           </select>

                <button type="submit">VALIDER</button>  </html>

You have to use Ajax for this problem. 您必须使用Ajax解决此问题。 You cant get populated dropdown list based on another dropdown list without refreshing the page. 您不能在不刷新页面的情况下基于另一个下拉列表获取填充的下拉列表。 So, the only option is to use Ajax . 因此,唯一的选择是使用Ajax

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM