I was thinking the same thing. But nevermind. On Tue, Jan 4, 2011 at 6:48 PM, Russ Michaels <[email protected]> wrote:
> > Still missing the point, but nevermind. > > -----Original Message----- > From: Michael Grant [mailto:[email protected]] > Sent: 04 January 2011 18:21 > To: cf-talk > Subject: Re: SOT: Show time in field on click > > > Right. But it's not the use of getElementById that "fixed" your code. It's > the fact you actually spelled the item correctly. Had you simply changed > "mydate" to "myDate" with your original code it would have worked fine. > > > > > On Tue, Jan 4, 2011 at 1:14 PM, Orlini, Robert <[email protected]> > wrote: > > > > > Michael, > > > > I have to agree despite my limited experience. My code below with the ID > > and the getElementById() works fine. Nonetheless, I appreciated your > > assistance. All suggestions worked to the final solution. I included the > > toLocaleTimeString(); > > code just to get the time and no date. > > > > Thanks agin. > > > > RO > > HWW > > > > <script type="text/javascript"> > > function show_now() { > > var my_time = new Date(); > > document.getElementById('myDate').value = my_time.toLocaleTimeString(); > > } > > </script> > > > > <form name="myForm"> > > <input type="text" name="myDate" id="myDate" size="9"> > > <input type=button value="Bounce Start Time" onclick="show_now();"> > > </form> > > > > -----Original Message----- > > From: "Russ Michaels" <[email protected]> > > Sent: Tuesday, January 4, 2011 1:05pm > > To: "cf-talk" <[email protected]> > > Subject: Re: SOT: Show time in field on click > > > > > > Michael, > > > > you do indeed need an ID to be defined to use getElementById(), the clue > is > > in the function itself, it gets the DOM reference for an object by its > ID, > > if you do not have such an ID then it will not find the object. > > Feel free to look it up on the w3c site or similar. > > > > Russ > > > > On Tue, Jan 4, 2011 at 3:44 PM, Michael Grant <[email protected]> wrote: > > > > > > > > That's not true at all. You don't need id defined. > > > The following code is completely functional. > > > <html> > > > <head> > > > <script type="text/javascript"> > > > function show_now() { > > > > > > var my_time = new Date(); > > > > > > document.myForm.myDate.value = my_time; > > > > > > } > > > </script> > > > </head> > > > <body> > > > <form name="myForm"> > > > <input name="myDate" type="text" size="10" /> > > > <input type=button value="Show Time" onclick="show_now();"> > > > </form> > > > </body> > > > </html> > > > > > > On Tue, Jan 4, 2011 at 10:36 AM, Russ Michaels <[email protected]> > > > wrote: > > > > > > > > > > > try this > > > > > > > > document.getElementById('myDate').value = my_time; > > > > > > > > your field must have an id of "myDate" > > > > > > > > e.g. > > > > <input type="text" name="myDate" id="myDate"> > > > > > > > > Russ > > > > On Tue, Jan 4, 2011 at 3:27 PM, Michael Grant <[email protected]> > wrote: > > > > > > > > > > > > > > No, they refer to the name attribute. > > > > > Otherwise it's document.getElementById("myDate"). > > > > > > > > > > > > > > > On Tue, Jan 4, 2011 at 10:26 AM, Ian Skinner <[email protected]> > wrote: > > > > > > > > > > > > > > > > > On 1/4/2011 7:16 AM, Orlini, Robert wrote: > > > > > > > Still not showing when I click the button. I also tried putting > > > > my_time > > > > > > into the field. > > > > > > > > > > > > > > RO > > > > > > > > > > > > document.myForm.myDate.value = my_time; > > > > > > > > > > > > IIRC, I believe that those refer to the ID's of DOM elements, not > > > > names. > > > > > > Try changing your form to. > > > > > > > > > > > > <form id="myForm"> > > > > > > <input id="myDate" type="text" size="10" /> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:340461 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm

