Jump to content

Code to Edit YYYY in Form Dropdown Box


dwappes

Recommended Posts

I have a PHP string as follows:

 

selectList( "field_4_YYYY", $_POST["field_4_YYYY"], date("Y")-18, date("Y"), "YYYY", $style ) ;

 

This (the -18) allows my dropdown box to display the year going back to 1992, which is what I want. However, it also displays all the years to present, as in 2008, 2009 & 2010, which is what I don't want. I only want the available years in the dropdown box to display 1992, 1993, 1994 & 1995.

 

Can someone please show me what changes need to be made to this string to do that that will automatically update annually? I want the years to always remain at between 15 to 18 years back. Thanks you!

Link to comment
Share on other sites

it's impossible to know for sure, since this function is user-defined (ie. not a native PHP function) and therefore we don't know how it's supposed to work. however, i'm going to take a stab and say that the parameter after date("Y")-18 is the upper boundary. try changing that one to date("Y")-15 and see what you get:

 

selectList( "field_4_YYYY", $_POST["field_4_YYYY"], date("Y")-18, date("Y")-15, "YYYY", $style ) ;

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.