TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 12-05-2012, 02:44 AM   #1 (permalink)
The Wanderer
 
Join Date: Jan 2010
Posts: 13
Thanks: 0
pepelepew1962 is on a distinguished road
Default JScript - 24hrs with leading zero ...

Hello:

I found this great calendar program that has 1 main fault. It does not display 24hrs with the leading zero. I think the below code is the root of the problem. Can anyone help me here please as I know no JScript:


//Time Picker

function tPicker(timeFieldId) {
var timeField = $(timeFieldId);
var hhmm;

//compute tpicker coordinates (beneath timeField)
var x = timeField.offsetLeft + timeField.offsetWidth + 22;
var y = timeField.offsetTop - 95;

//deal with elements inside tables and such
var parent = timeField;
while (parent.offsetParent) {
parent = parent.offsetParent;
x += parent.offsetLeft;
y += parent.offsetTop ;
}

//If not present, create tpDiv, move it to x,y and toggle visibility
var tpDiv = createDiv("tpDiv", x, y);

//draw the timepicker table; the timeField object will receive the time
var html='<div class="tpFrame">';
var apm = /\s*a/i.exec(tFormat);
if (apm != null) {
var am = String(apm).replace("a","am").replace("A","AM");
var pm = String(apm).replace("a","pm").replace("A","PM");
}
if (apm != null) { html += '- AM -'; }
for (var i=7;i<24;i++){
if (i==7) { html += '<div class="tpAM">'; }
if (i==12 && (apm != null)) { html += '- PM -'; }
if (i==12) { html += '<div class="tpPM">'; }
if (i==18) { html += '<div class="tpEM">'; }
for (var j=0;j<60;j += 15) {
if (apm != null) {
hh = i;
ampm = (hh < 12) ? am : pm;
if (hh >= 13) { hh -= 12; }
hhmm1 = String(hh) + ":" + String("0" + j).slice(-2) + ampm;
hhmm2 = String("0" + hh).slice(-2) + ":" + String("0" + j).slice(-2);
} else {
hhmm1 = hhmm2 = String("0" + i).slice(-2) + ":" + String("0" + j).slice(-2)
}
html += '<a class="tpPick" href="#" onclick="updateTimeField(\''+timeFieldId+'\', \''+hhmm1+'\');">'+hhmm2+'</a>';
if (j<45) { html += '&nbsp;&nbsp;'; }
}
html += (i==11 || i==17 || i==23) ? '</div>' : '<br>';
}
html += '</div>';
tpDiv.innerHTML = html;
}

function updateTimeField(timeFieldId, timeString) {
var timeField = $(timeFieldId);
if (timeString) { timeField.value = timeString; }
var tpDiv = $("tpDiv");
tpDiv.style.visibility = "hidden";
tpDiv.style.display = "none";
timeField.focus();
}
pepelepew1962 is offline  
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT. The time now is 11:33 PM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design