I have the following code:
I’m completely new to javascript, this is my first time using it. The values of the HTML selects MUST be 01,02 etc, that’s why I had to use a big long if else statement. The values have to be submitted to an application on a server, which is extremely fussy about what way it takes in values.
Why won’t it set the day as 15 (today) in the select box?
You have a few issues, you’re not including jQuery on the left, the element has a name not an ID or
CID, so it needs to beid="CID"or your selector needs to beselect[name='CID']. Last, you need to pass a string to.val()to get the result you want, otherwise it’s trying to set it to"4", which doesn’t equal"04".You can shorten all your code down to this though:
You can test it here, also as Jamiec points out, you want
.getDate()to get the date of the month as opposed to.getDay()which is of the week.