views:

58

answers:

2
A: 

Doing that you will need a huge database in the backend with every day of every special day. But it might not work as there are many special days on one day or even one special day might occur on two days.

If you have only one day per date, I would send the date (or the description of the day) to the backend and then return the possible suggestions. I would even enable autocompletion for the description if you don't have any date set.

In the response for the description I would show both, the text and the date in bracets and then add the date to the first input, as soon as the user selects an option.

Kau-Boy
A: 

Use the onchange event. Using jQuery...

$('#dateInputId').change( function() {
    if ($(this).val().substring(0, 5) === '12/25') {
        $('#secondInputId').val('Christmas');
    } else {
        $('#secondInputId').val('');
    }
});
jasongetsdown
Edit your initial post and add the code there. FYI when typing code in comments use the backquote (left of your 1 key) before and after your snippet instead of [code][/code]. For longer pieces of code in a question of answer (doesn't work in comments) highlight the code and click the toolbar button that says 1010101. This will preserve indentation like my code above.
jasongetsdown
I tried the backquote (`) to show code snippet. It does show?
oneofthelions
With a few adjustments it works: http://jsbin.com/usovi3/edit. You've got a typo or two in there, and I'm not sure why you're doing `$(function() {...})`. That passes a function to jQuery, which doesn't work. I'm assuming what you meant to do is either use an anonymous function block to create a private scope like `(function() {...})();` or execute when the DOM is ready with `$(document).ready(function() {...});`.
jasongetsdown
and auto complete wasn't working because you didn't change the id when you copied the example from the jQuery UI page :) Updated version... http://jsbin.com/usovi3/2/edit
jasongetsdown
Also, if someone posts an answer that solves your problem click the green check mark to give them some props :)
jasongetsdown
Jason: what do you mean by '101010' on the toolbar. There is no toolbar on my webpage??
oneofthelions
If you click the edit link at the bottom of your question post there should be a toolbar over the text box containing your post. One of the buttons has an image of binary ones and zeros to represent code.
jasongetsdown