473,406 Members | 2,387 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Time in combobox

Hi,
I need to display the time in combo box like the one we have it in
Wndows 2000.
we can change the time using the arrow.. it looks like this:

4:40:54 PM

in a combo box .
i need to do it like his in my page.
waiting for ur response.
Ciao,
jay

Jul 1 '06 #1
2 2122
ja*********@gmail.com wrote:
I need to display the time in combo box like the one we have it in
Wndows 2000.
we can change the time using the arrow.. it looks like this:

4:40:54 PM

in a combo box .
i need to do it like his in my page.


<html>

<head>
<meta http-equiv="Content-Type"
content="text/html; charset=iso-8859-1">
<script type="text/javascript">

var usrHours = 0;
var usrMinutes = 0;
var usrSeconds = 0;

function showTime(h,m,s) {

var now = new Date();

if (
now.getHours() + usrHours + h > 23 ||
now.getHours() + usrHours + h < 0 ||
now.getMinutes() + usrMinutes + m > 59 ||
now.getMinutes() + usrMinutes + m < 0 ||
now.getSeconds() + usrSeconds + s > 59 ||
now.getSeconds() + usrSeconds + s < 0
) {
return false;
}

usrHours+=h;
usrMinutes+=m;
usrSeconds+=s;
var hours = now.getHours() + usrHours;
var minutes = now.getMinutes() + usrMinutes;
var seconds = now.getSeconds() + usrSeconds;
var timeNow = hours;
if (hours >= 12) {
timeNow -= 12;
var ext = 'PM';
}
else {
var ext = 'AM';
}

timeNow += ((minutes < 10) ? ':0' : ':') + minutes;
timeNow += ((seconds < 10) ? ':0' : ':') + seconds;
timeNow += ' ' + ext ;
document.f.myCombo.value = timeNow;
setTimeout('showTime(0,0,0)', 1000);

}

</script>
</head>

<body onLoad="showTime(0,0,0);">
<form name="f">
<input size="13" name="myCombo">
</form>
<br>
<input type="button" value="hrs++" onClick="showTime(1,0,0);">
<input type="button" value="hrs--" onClick="showTime(-1,0,0);">
<input type="button" value="min++" onClick="showTime(0,1,0);">
<input type="button" value="min--" onClick="showTime(0,-1,0);">
<input type="button" value="sec++" onClick="showTime(0,0,1);">
<input type="button" value="sec--" onClick="showTime(0,0,-1);">
<input type="button" value="Reset"
onClick="usrHours=usrMinutes=usrSeconds=0; showTime(0,0,0);">
<hr>
Max value of seconds and minutes is 59.<br>
Min value of seconds and minutes is 0.<br>
Max value of hours is 11 PM.<br>
Min value of hours is 0 AM.
</body>

</html>

Hope this helps,

--
Bart

Jul 1 '06 #2
JRS: In article <11*********************@j8g2000cwa.googlegroups.c om>,
dated Sat, 1 Jul 2006 05:29:59 remote, seen in
news:comp.lang.javascript, Bart Van der Donck <ba**@nijlen.composted :
>
Hope this helps,
Better to encourage the use of the sensible 24-hour notation, which is
easier. Your code shows 0 AM & 0 PM, which is not customary in English-
speaking countries.

ISTM that one should probably stop the clock on the first click.

I think it would be better to use a Date Object, and, at each button-
click, add 1000 * +-1 * (1 or 60 or 3600) using setTime, and display it.
Then one gets automatic rollover, and cannot (in the Netherlands) on
2006-03-26 set a time between, if I have it right, 02:00:00 to 02:59:59.

I won't code it, because I consider it much easier just to type the
desired time as hh:mm:ss.
** OP : DO NOT MULTI-POST ***

--
© John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 MIME. ©
Web <URL:http://www.merlyn.demon.co.uk/- w. FAQish topics, links, acronyms
PAS EXE etc : <URL:http://www.merlyn.demon.co.uk/programs/- see 00index.htm
Dates - miscdate.htm moredate.htm js-dates.htm pas-time.htm critdate.htm etc.
Jul 1 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Zlatko Matić | last post by:
There is a form (single form) and a combobox. I want that current record of the form is adjusted according to selected value in the combobox. Cuurrent record should be the same as the value in the...
3
by: TT (Tom Tempelaere) | last post by:
Hay there, I'm writing my own DataGridComboBoxColumn because .NET 1.1 does not have one (I hope .NET 2.0 supplies one). I based it on this article:...
4
by: jim | last post by:
I am trying to debug a user written web control and web control designer. I found an article “Building Windows Forms Controls and Component with Rich Design-Time Features” that describes how...
13
by: KKuser | last post by:
Hello: I have 20, 30 text and combo boxes on one form, and I would like to clear them up at one time using the statement "With..........End With". I used this when using VB6, but I don't know...
5
by: Chaos2651 | last post by:
I have Visual Studio .NET with all of the components installed onto it. I want to add items to a combo box at run-time through numerous subroutines. I previously did it with the combo boxes AddItem...
6
by: chreo | last post by:
Sorry for weird title and sorry for my English (I'm from Poland). This is the problem: I have form with many controls. There are three comboboxes - each should have table STREETS as DataSource....
0
by: zhuang | last post by:
Hi, Adding combobox to datagrid has been posted many times. I have a datagrid which has multiple combobox columns and normal textbox columns. But how could I change other combo box values at...
2
by: autenzio | last post by:
I want to be able to load up the items collection of a combobox with string values I create in Application settings. I have created a collection of strings in the Settings window, but I am unable...
0
by: fiaolle | last post by:
Hi I have a combobox wich I set the Datasource,Displaymember and Valuemember at design time. I'm using a Dataset's table. But when I run the form the combobox isn't filled. Can't I set properties...
5
by: active | last post by:
I tried to use a datasource with a combobox and it didn't work completely so I build a small test that was much more straight forward then the app. The test was to see if the combobox dropdown...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.