Patrick Lanfranco
Patrick Lanfranco

Reputation: 309

transfer values of select boxes to hidden field

I have three select boxes, one to select the year, another one for the month and the last one for the day. My goal is to have them automatically inserted into one hidden field (resulting in e.g. 2012-07-16) which is the main "date" field and that get's stored into the database.

Does anyone have an idea how this can be best achieved? Some advise would be highly appreciated, thank you very much, Patrick

Upvotes: 0

Views: 115

Answers (2)

Nirmal
Nirmal

Reputation: 4829

Working example using plain javascript, u may change it to jquery.

http://jsfiddle.net/R3yeX/

Upvotes: 0

Mihai Stancu
Mihai Stancu

Reputation: 16107

$('#year, #month, #day').change(function() {
    $('#date').val($('#year').val()+'-'+$('#month').val()+'-'+$('#ay').val())
});

Upvotes: 2

Related Questions