my problem is the following.
I have an HTML file, a .XML file and a jQuery file.
In the first one i have two select tags, first of them is visible and the second is hidden. If i choose the option that have that specific value, the second select box will appear, else instead it will be hidden.
In the xml are contained the items that i want to show in one particular select box.
In the jQuery file i load the xml via Ajax and i append to the id of the first select the option tag that have to contain some specific nodes.
I've noted that if i manually create the option tags with their values in the HTML, if with jQuery i search for that value, it will work. If instead i append the option tags to the jQuery select id, then the option tag will not find their values.
This is the example in short
HTML
<select id="selectProvincia"></select>
<select id="selectSede"></select>
XML
<province>
<provincia value="PE">Pescara</provincia>
<provincia value="TE">Teramo</provincia>
<provincia value="AQ">L'Aquila</provincia>
<provincia value="CH">Chieti</provincia>
<provincia value="AN">Ancona</provincia>
</province>
jQuery
I load provincia items and i create option tags
$(xml).find('provincia').each(function(){
var provincia = $(this).text();
$("#selectProvincia").append("<option value='" + provincia + "'>" + provincia + "</option>");
});
Is that value? Show Isn't that? Hide
$('#selectProvincia').bind('change', function (e) {
if( $('#test').val() == "TE") {
alert('Ciao ciao.');
$('#sedeSelect').show();
}
else{
$('<p>Oh!</p>').hide();
}
});
This doesn't work.
If i say in HTML
<select id="test">
<option value="1">Hello World</option>
</select>
Then it works.
Why?
Thanks.
Oh!
').hide(); } }); was not the correct one? – Alessandro Violante Jun 09 '13 at 16:58