Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > onlick insert date

Reply
Thread Tools

onlick insert date

 
 
Terje
Guest
Posts: n/a
 
      11-17-2004
Have the following code on a checkbox

onClick="oppdater_levering.leveringsdato.value=eva l(<?php echo date('Y-m-d')
?>)"

This should insert todays date into leveringsdato in the form
oppdater_levering, but in a strange way I get only displayed a strange year
1976, anyone that can tell me how to make out this?

Terje



 
Reply With Quote
 
 
 
 
Erwin Moller
Guest
Posts: n/a
 
      11-17-2004
Terje wrote:

> Have the following code on a checkbox
>
> onClick="oppdater_levering.leveringsdato.value=eva l(<?php echo
> date('Y-m-d') ?>)"
>
> This should insert todays date into leveringsdato in the form
> oppdater_levering, but in a strange way I get only displayed a strange
> year 1976, anyone that can tell me how to make out this?
>
> Terje


Hi,

Why do you use eval?
I don't think Javascript wants to eval something like:

2004-4-14

That makes no sense.

Try this:
onClick="oppdater_levering.leveringsdato.value=<?p hp echo date('Y-m-d') ?>)"

Regards,
Erwin Moller

 
Reply With Quote
 
 
 
 
Terje
Guest
Posts: n/a
 
      11-17-2004
> Try this:
> onClick="oppdater_levering.leveringsdato.value=<?p hp echo date('Y-m-d')

?>)"
>
> Regards,
> Erwin Moller


Have tryed both versions, but still I only get "1976" displayed

Terje


 
Reply With Quote
 
Evertjan.
Guest
Posts: n/a
 
      11-17-2004
Terje wrote on 17 nov 2004 in comp.lang.javascript:
>> Try this:
>> onClick="oppdater_levering.leveringsdato.value=<?p hp echo date('Y-m-d')

> ?>)"
>
> Have tryed both versions, but still I only get "1976" displayed


Single quote the value.
[Always look at the rendered HTML with view source]


onClick=
"oppdater_levering.leveringsdato.value=
'<?php echo date('Y-m-d')?>'; "



--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress,
but let us keep the discussions in the newsgroup)

 
Reply With Quote
 
Terje
Guest
Posts: n/a
 
      11-17-2004
> Single quote the value.
> [Always look at the rendered HTML with view source]
>
>
> onClick=
> "oppdater_levering.leveringsdato.value=
> '<?php echo date('Y-m-d')?>'; "


Tanks, I've first I made it with a JS dateobject but since this depends on
that the user have the right timeconfiguration its mutch better to get the
date from the server with php. This made it work.

Terje


 
Reply With Quote
 
 
 
Reply

Thread Tools

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

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
mixing onlick functions in link_to_function Mike Dershowitz Ruby 2 06-02-2007 09:38 PM
problem adding onlick attribute to Button from CodeBehind Lars Netzel ASP .Net 2 04-07-2005 12:40 PM
2 onlick events? DC Gringo ASP .Net 4 11-02-2004 11:58 PM
2 onlick events? DC Gringo ASP .Net Building Controls 4 11-02-2004 11:58 PM
Date, date date date.... Peter Grison Java 10 05-30-2004 01:20 PM



Advertisments