Datepicker – where to put the necessary files
-
I’m relatively new to WordPress and wouldn’t class myself as a developer, but with a bit of trial and error I usually get there.
However, I’ve been stumped on something for a couple of days now. I’ve looked at the forum threads (many of the most recent related ones are 3 years+ old) and I’ve checked the codex and it’s still not clear to me what I need to do. It’s possible that it’s my (mis)interpretation of what’s written there, much like someone who made a similar enquiry some time back. The world and wordpress have also moved on since.
My needs are simple. I want to pass values from a form to Roman Cart. One of the fields is a date field and I want to use the built-in jquery datepicker so that the user can select a formatted date.
Everyone’s saying that there’s a ‘right way’ to do this, but there is conflicting info about that way, it seems in terms of where to place or reference the necessary libraries, functions etc. I’ve read about wp_enqueue, functions.php, header.php etc in terms of what needs to change. I also know that the datepicker function/code is now bundled with wordpress, but needs to be called on each use (I think).
So far, I have tried two different approaches without success, both of which you’ll see one above the other at https://m.xmarksthespot.co.uk/test-cart.
In the first option – probably my preferred option – the form ‘works’ and passes the values however I can only get it to work by putting the jquery links, calls etc on the same page as the form. I know this is wrong, but I don’t know exactly what needs to go where in terms of references to jquery, stylesheet links or function calls. A side effect is that the page header text initially briefly appears larger when loaded, and also there is extra white space at the bottom caused by the code that ought to be in <head> tags somewhere I presume?
In my second option I’ve used contact form 7 plug-in and jquery datepicker and don’t have the same issues as in option 1 with placement of jquery, function calls etc as presumably the plug-in is taking care of this for me in a satisfactory manner. However I don’t know how to pass the form input values onwards (instead of the standard use of contact 7 for sending an email). I tried redirecting using ‘alternative options’ without success.
As I said if option 1 can be cracked that would be preferred as I think it’s a cleaner solution and doesn’t rely on a form plug-in.
I am running WordPress 4.5.1, a Twenty Ten Child theme and WP Touch Pro.
Any advice greatly appreciated!
- The topic ‘Datepicker – where to put the necessary files’ is closed to new replies.