表单从数据库获取数据(servlet + Jsp)

时间:2022-08-19 11:48:32

In my form, I have a a select option like this:

在我的表单中,我有一个像这样的选择选项:

http://zaielacademic.net/java_jsp_servlets_mysql/forms_sticky_all.htm

But I have also a function onchange. How can I use it with this code? I get the value selected from the servlet. I think I must use another function (onselect)?

但我还有一个函数onchange。如何在此代码中使用它?我从servlet中选择了值。我想我必须使用另一个功能(onselect)?

<select name="situation" id="type"   class="form-control i9" >
   <option value="cle" <% if (proSituation.equals("cle")) out.print("selected"); %> >Célibataire</option>
   <option value="marie" <% if (proSituation.equals("marie")) out.print("selected"); %> >Marié</option>
   <option value="div" <% if (proSituation.equals("div")) out.print("selected"); %> >Divorcé</option>
   <option value="veuf" <% if (proSituation.equals("veuf")) out.print("selected"); %> >Veuf</option>
</select>

1 个解决方案

#1


0  

if the select value is "marie" then they call function

如果选择值是“marie”,那么他们调用函数

onchange="SituationFalilliale(this.value)

   function  SituationFalilliale(selection) {

switch(selection) { case 'marie': $('#conjoint').show(); break; default: $('#conjoint').hide(); break; }

switch(selection){case'marie':$('#conjoint')。show();打破;默认值:$('#conjoint')。hide();打破; }

}

it is ok with onchange but i want is auto show it if value is "marie" not with onchange

它是正常的onchange但我想要是自动显示它,如果值是“marie”而不是onchange

#1


0  

if the select value is "marie" then they call function

如果选择值是“marie”,那么他们调用函数

onchange="SituationFalilliale(this.value)

   function  SituationFalilliale(selection) {

switch(selection) { case 'marie': $('#conjoint').show(); break; default: $('#conjoint').hide(); break; }

switch(selection){case'marie':$('#conjoint')。show();打破;默认值:$('#conjoint')。hide();打破; }

}

it is ok with onchange but i want is auto show it if value is "marie" not with onchange

它是正常的onchange但我想要是自动显示它,如果值是“marie”而不是onchange