Adding time to a date timestamp based on user's selection
I have a form where jQuery is already being used on page load to change a value to a timestamp with the following format: 20110424. It's a hidden input field:
<input type="hidden" name="sub_enddate" value="1" />
Which when the page is run, the value of "1" gets changed to one month out. If "2" is in the value, the value of 2 is replaced with "20110524" and so on. It's using the following code to make this change: http://pastie.org/1708677
What I'm trying to do now is change the date value above based on select values a user chooses. Here's the select options:
<select name="Membership Duration">
<option value="">Select A Membership Duration</option>
<option class="mos6" value="6 Months{p+220}">6 Month Membership</option>
<option class="mos3" value="3 Months{p+240}">3 Month Membership</option>
<option class="mos1" value="1 Months{p+260}">1 Month Membership</option>
</select>
As you can see, I've attached a class to each option in the select dropdowns (i.e. mos6). What I'm attempting to do is change the value of the timestamp explained above based on what the user chooses. For example, if the user chooses "3 Month Membership", since this option has a class of 3, the timestamp will be modified to reflect 3 months from today's date (so effectively adding 2 months onto the existing timestamp in the开发者_JAVA百科 hidden input field above. If "6 Month Membership" is chosen, the date will be modified to 6 months from today's date and so on. If the hidden input field above is a bad idea and we should just create a timestamp instead based on the dropdown options, I'm cool with that.
Thanks!
I was able to track it down by asking a different question here: How to timestamp with jQuery based off user's selection
精彩评论