Advanced Search

Results 1 to 4 of 4

Thread: JScript - 24hrs with leading zero ...

  1. #1
    Join Date
    Nov 2008
    Posts
    42
    Thanks
    2
    Thanked 0 Times in 0 Posts

    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:


    Code:
    //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();
    }
    Last edited by keyboard; 12-05-2012 at 06:02 AM. Reason: Format: Code Tags [code][/code]

  2. #2
    Join Date
    Jul 2008
    Location
    Derbyshire, UK
    Posts
    1,881
    Thanks
    16
    Thanked 288 Times in 287 Posts
    Blog Entries
    4

    Default

    With the snippet of information you provided, I Googled a random line of code and found that its from the "common/dtpicker.js" file bundled with LuxCal: http://www.luxsoft.eu/

    Then having just done a quick search of their website, I see that your question has already been answered by the actual developer: http://www.luxsoft.eu/forum/index.php?a=vtopic&t=904

    What can we learn from this?

    1 - ask your question in the right place - the source is always the best place to start (especially when their help forum is current/active)

    2 - patience is a virtue - its reasonable to wait a few days for a reply before posting in other unrelated script forums

    3 - if you ask for help from elsewhere, provide the information upfront and dont expect others to go hunting for all the jigsaw pieces for you
    Focus on Function Web Design | Latest News RSS | Facebook | Twitter |
    Fast Edit (A flat file, PHP web page editor & CMS. Small, FREE, no database!) | Fast Edit BE (Snippet Manager) (Web content editor for multiple editable regions!) | Fast Apps |
    The only limit to creativity is imagination: JemCon.org

  3. #3
    Join Date
    Apr 2008
    Location
    So.Cal
    Posts
    3,621
    Thanks
    63
    Thanked 516 Times in 502 Posts
    Blog Entries
    5

    Default

    Quote Originally Posted by Beverleyh View Post
    3 - if you ask for help from elsewhere, provide the information upfront and dont expect others to go hunting for all the jigsaw pieces for you
    The fact that you did go to all that trouble doesn't really help reinforce that last point.
    We Only Torture the Folks We Don't Like (You're Probably Gonna Be Okay)
    It's a Party in the CIA

  4. #4
    Join Date
    Jul 2008
    Location
    Derbyshire, UK
    Posts
    1,881
    Thanks
    16
    Thanked 288 Times in 287 Posts
    Blog Entries
    4

    Default

    Yeh, I know. I went through the "steps from helpful to P'd-off";

    1. Maybe google isolated the script [innocent mistake - I'll try and put it back in context for them]
    2. Source site located
    3. A quick search for documentation
    4. Find recent thread title in help forum that looks promising [pleased cos its dated the same day]
    5. Read question
    6. Read name
    7. Read answer [oh so they *did* go to the source! They *did* know about and have access to the whole scripts! And they got an answer and didn't resolve the thread on DD!]
    8. Realise my own precious time has been wasted by a careless act of thoughtlessness and impatience
    9. Raaaaarrgghhh!
    Last edited by Beverleyh; 12-06-2012 at 05:53 AM.
    Focus on Function Web Design | Latest News RSS | Facebook | Twitter |
    Fast Edit (A flat file, PHP web page editor & CMS. Small, FREE, no database!) | Fast Edit BE (Snippet Manager) (Web content editor for multiple editable regions!) | Fast Apps |
    The only limit to creativity is imagination: JemCon.org

Similar Threads

  1. Preserve Leading Zeros Question
    By theflyingminstrel in forum ASP
    Replies: 6
    Last Post: 02-01-2009, 03:16 PM
  2. Countdown leading zero for single digits
    By spoonervt in forum Dynamic Drive scripts help
    Replies: 1
    Last Post: 03-01-2008, 01:43 PM
  3. Leading zeros
    By pavmoxo in forum PHP
    Replies: 6
    Last Post: 05-16-2006, 11:31 AM
  4. I want to put leading zero automatically
    By amit1234 in forum ASP
    Replies: 4
    Last Post: 09-02-2005, 07:56 AM
  5. Replies: 5
    Last Post: 11-17-2004, 02:11 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •