Mon script fonctionne sijavascript erreur
<script type="text/javascript">
$(document).ready(function() {
$('#holidayDate').datepicker();
var availableTags = ["New years Day", "Martin Luther King Day", "Groundhog Day", "Valentine's Day", "Washington's Birthday", "Easter", "Earth Day", "National Arbor Day", "Mother's Day", "Memorial Day", "Flag Day", "Father's Day", "Independence Day", "Labor Day", "Columbus Day", "Halloween", "Veterans Day", "Thanksgiving Day", "Pearl Harbor Remembrance Day", "Christmas Day"];
$("#tags").autocomplete({source:availableTags});
$('#holidayDate').change(function() {
if ($(this).val().substring(0, 5) === '12/25') {
$('#tags').val('Christmas Day');
}
else {
$('#tags').val('');
}
});
});
</script>
Et sa ne fonctionne pas si j'inclure plusieurs valeurs à l'aide "si" ou "else if"
<script type="text/javascript">
$(document).ready(function() {
$('#holidayDate').datepicker();
var availableTags = ["New years Day", "Martin Luther King Day", "Groundhog Day", "Valentine's Day", "Washington's Birthday", "Easter", "Earth Day", "National Arbor Day", "Mother's Day", "Memorial Day", "Flag Day", "Father's Day", "Independence Day", "Labor Day", "Columbus Day", "Halloween", "Veterans Day", "Thanksgiving Day", "Pearl Harbor Remembrance Day", "Christmas Day"];
$("#tags").autocomplete({source:availableTags});
$('#holidayDate').change(function() {
if ($(this).val().substring(0, 5) === '12/25') {
$('#tags').val('Christmas Day');
}
if ($(this).val().substring(0, 5) === '01/01') {
$('#tags').val('New years Day');
}
if ($(this).val().substring(0, 5) === '02/02') {
$('#tags').val('Groundhog Day');
}
if ($(this).val().substring(0, 5) === '02/14') {
$('#tags').val('Valentine's Day');
}
if ($(this).val().substring(0, 5) === '04/22') {
$('#tags').val('Earth Day');
}
if ($(this).val().substring(0, 5) === '10/12') {
$('#tags').val('Columbus Day');
}
if ($(this).val().substring(0, 5) === '07/04') {
$('#tags').val('Independence Day');
}
if ($(this).val().substring(0, 5) === '10/31') {
$('#tags').val('Halloween');
}
if ($(this).val().substring(0, 5) === '11/11') {
$('#tags').val('Veterans Day');
}
if ($(this).val().substring(0, 5) === '12/07') {
$('#tags').val('Pearl Harbor Remembrance Day');
}
else {
$('#tags').val('');
}
});
});
</script>
Vous pouvez reformater un peu pour que ce soit un li plus facile à suivre –
Semble que [code] ne fonctionne pas - mettez en surbrillance le code et cliquez sur le bouton 101010 – mplungjan
Avez-vous essayé d'utiliser FIREBUG? ;) C'est une bouée de sauvetage! – Jakub