Author Topic: Time Zone 'picker' (for PHP values)  (Read 1315 times)

0 Members and 2 Guests are viewing this topic.

Offline the beteljuice

  • the beteljuice
  • Forecaster
  • *****
  • Posts: 316
    • test site
Time Zone 'picker' (for PHP values)
« 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

tz_picker.php?set=Africa/Cairo

tz_picker.php?place=Africa/Cairo

NEW: even BETTER example 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
« Last Edit: November 06, 2018, 09:13:58 PM by beteljuice »
Imagine what you will KNOW tomorrow !

Offline the beteljuice

  • the beteljuice
  • Forecaster
  • *****
  • Posts: 316
    • test site
Update: Time Zone 'picker' (for PHP values)
« Reply #1 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.
Imagine what you will KNOW tomorrow !

 

anything