Vote count:
0
i have 2 selects that return values from a database with the second select depending on the first select. The SAMPAREA select returns values like XX345,XXab,XX2e,XX and SAMPCOUNTRY returns just XX values.
I need just to take the XX value from SAMPAREA to compare to the XX value from SAMPCOUNTRY and substring doesn't seem to work at all, i still get only the values with just XX in them from SAMPAREA.
This is the jquery.
$("#sampcountry").change(function() {
if($(this).data('options') === undefined){
$(this).data('options',$('#samparea option').clone());
}
var str = $(this).val();
var id = str.substring(0,2);
var options = $(this).data('options').filter('[value=' + id + ']');
$('#samparea').html(options);
});
And this is the jsp.
<td><select id="sampcountry" name="sampcountry" onblur="return validate2(this);" title="Ţara în care a fost prelevata proba (ISO 3166-1-alpha-2).">
<option value=""/>
<%ResultSet rs1 = st.executeQuery("select code,name from country");
while(rs1.next()){
%>
<option value="<%=rs1.getString("code")%>"><%=rs1.getString("name")%></option>
<%}%>
</select></td>
<td><select id="samparea" name="samparea" style="width: 300px" title="Zona în care a fost prelevată proba (Nomenclatorul Unităţilor Teritoriale pentru Statistică NUTS – sistem de coduri valabil doar pentru ţările membre UE şi Elveţia).">
<option value=""/>
<% ResultSet rs2 = st.executeQuery("select code,name from nuts");
while(rs2.next()){
%>
<option value="<%=rs2.getString("code")%>"><%=rs2.getString("name")%></option>
<%}%>
</select></td>
asked 1 min ago
Aucun commentaire:
Enregistrer un commentaire