Win a copy of Beginning Java 17 Fundamentals: Object-Oriented Programming in Java 17 this week in the Java in General forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

onclick event

 
Ranch Hand
Posts: 112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I have this javascript fuunction and wehn I try to call it on onclick event it say object doesn't support this property?? Can anyone help me out here
thanks in advance
-PC
-----------------------------------
function today(form){
var d = new Date();
var todaydate= d.getFullYear()+"-"+(d.getMonth() + 1)+"-"+d.getDate();
document.form.modificationDate.value=todaydate;
}
-------------------------------------
 
Ranch Hand
Posts: 103
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Priyanka Chopda:
Hi,
I have this javascript fuunction and wehn I try to call it on onclick event it say object doesn't support this property?? Can anyone help me out here
thanks in advance
-PC
-----------------------------------
function today(form){
var d = new Date();
var todaydate= d.getFullYear()+"-"+(d.getMonth() + 1)+"-"+d.getDate();
document.form.modificationDate.value=todaydate;
}
-------------------------------------


Hi Priyanka,
I just created a simple example and it worked.
I think the problem is @ document.form.modificationDate.value=todaydate;
Did you create FORM tags in your html code and/or did you give a form name.
If you did not create a form name just call any name and replace it with the form
Hope this helps.
[ September 26, 2003: Message edited by: sam patel ]
 
Ranch Hand
Posts: 1061
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
what is the parameter "form" good for?
I assume it's the name of the form, wich named differently (not "form").
1. form is an JavaScript Object. Use another name.
2. If you intend to get access to the parameter's properties use it without "document".

If it doesn't work, it would be helpful if you posted how you call today()
hth cb
[ September 26, 2003: Message edited by: Chris Baron ]
 
Priyanka Chopda
Ranch Hand
Posts: 112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm calling in submit type as
today(this.form)
-PC
 
Chris Baron
Ranch Hand
Posts: 1061
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Know what's happening?
The form does what it's job is... it submits, faster than one can see
if you call it with return and you return false for testing you can see it's working:


<html><head>
<script>
<!--
function today(parameter)
{
var d = new Date();
var todaydate= d.getFullYear()+"-"+(d.getMonth() + 1)+"-"+d.getDate();
parameter.modificationDate.value=todaydate;

return false; //Set this to "true" in production
}
//-->
</script>
</head><body>
<form name="abc" action="#">
<input type="text" name="modificationDate">
<input type="submit" onclick="return today(this.form)">
</form>
</body></html>

 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic