WXforum.net

Miscellaneous Debris => Tech Corner => Topic started by: the beteljuice on October 31, 2018, 09:32:24 PM

Title: Time Zone 'picker' (for PHP values)
Post by: the beteljuice on October 31, 2018, 09:32:24 PM
Once again the beteljuice has trouble deciding which area to post code / code snippets.
Apologies if in the wrong thread.

The beteljuice had need of a 'friendly' visitor timezone setter (for working in PHP)

So ......

// beteljuice - Nov 2018
// List is 2011 - one of many in different lengths / formats on github
// list of valid(?) php timezones
// create a drop-down like text box that presents 'auto-complete' options
// NOTE: onchange etc. won't happen until a click OUTSIDE the 'box'
// 'posting' eg. this.php?set=Africa/Cairo will make the value 'selected' for javascript
//    AND put it as the text in the pretend select box (more of an advisory)
// 'posting' eg. this.php?place=Africa/Cairo will make the value 'selected' for javascript
//     BUT text in the pretend select box will read "(Start typing ...)"
/* When used as PHP include ...
     <? $set="Europe/Warsaw"; include_once "this.php"; ?>
*/

When I'd created it, It realised it only ever had to be run once  :shock:

Why ? - Well it pastes in html so you only need to run it and then 'view source'  #-o
You could then cut'n'paste that into your page, or (for 'view source' legibility) split it into two .txt files which you could 'include' in a php page !

Suck it and see ....

tz_picker.php (http://www.beteljuice.com/DEMOS/tz_picker.php)

tz_picker.php?set=Africa/Cairo (http://www.beteljuice.com/DEMOS/tz_picker.php?set=Africa/Cairo)

tz_picker.php?place=Africa/Cairo (http://www.beteljuice.com/DEMOS/tz_picker.php?place=Africa/Cairo)

NEW: even BETTER example (http://beteljuice.com/DEMOS/handler.php) with a HTML5 <datalist> 'handler' which makes it able to execute something as soon as filtered valid selection is made.

If you'd like the actual php file:
 [ You are not allowed to view attachments ]  

Please note: This will add nearly 500 lines to your html code  :lol:

... 'tis another beteljuice plaything
Title: Update: Time Zone 'picker' (for PHP values)
Post by: the beteljuice on November 06, 2018, 09:07:38 PM
The file 'as is' works great in a <form><submit> environment, but was unable to 'self - fire' an event because of the vagaries of HTML5 <datalist>.

i.e. There is no 'change' event until a user clicks anything outside of the 'input' text box.

It is not possible says the web, although there are many, many, many, snippets out there none of which actually work  :roll:

... until now  :grin:

New example link given above that tells you how to do it.