Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Javascript Populate field troubles

Status
Not open for further replies.

CHRISWYA

IS-IT--Management
Sep 14, 2004
19
GB
Hi guys!
i have encountered a bit of a problem and have been struggling to solve it with my basic javascript knowledge. What i am after is a script that when p_close_date has data is populated the script willpopulate p_close_time with the current time, although not SYSDATE as such because i dont want the time to change once the field has been populated.

I know this is a weird request cos there is no basic code as such but any help would be greatly appreciated. Below is Pseudo code which reiterates what i hope to achieve

{
if (theForm.p_close_date.value IS NOT NULL)
{
the form.p_close_time.value = TO_CHAR(SYSDATE, 'HH24:MI')
}
 
Try this -

if (theForm.p_close_date.value IS NOT NULL)
{
var d = new Date()
the form.p_close_time.value = d.getHours() + "." +
d.getMinutes() + "." + d.getSeconds();
}

Cheers

Stewart

Stewart Webb
Goldcrest Computer Services
 
Your field:
Code:
<input type="text" name="p_close_date" onchange="doTheThing();">

Your function between the [tt]<head></head>[/tt] tags:
Code:
function doTheThing() {
    var cd = document.forms['form_name'].elements['p_close_date'];
    var ct = document.forms['form_name'].elements['p_close_time'];
    var dt = new Date();
    if (cd.value != '')
        ct.value = dt.getHours() + ":" + dt.getMinutes() + ":" + dt.getSeconds();
}

*cLFlaVA
----------------------------
Lois: "Peter, you're drunk!"
Peter: "I'm not drunk, I'm just exhausted from stayin' up all night drinking!
 
thanks very much lads for both ur help haven't got it quite working yet but im sure with a combination of ur help all get there


cheers
 
Maybe go into a little more detail, some code samples, your html form, etc.

*cLFlaVA
----------------------------
Lois: "Peter, you're drunk!"
Peter: "I'm not drunk, I'm just exhausted from stayin' up all night drinking!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top