TonyReid
Posts: 159
|
| Posted: 06/02/2006, 5:55 AM |
|
Im taking my first steps into javascript
What I am intending on doing is using the ondblclick event (under format tab of text field property) to insert the current date.
In effect - clicking on the text field inserts the current date.
I have got it to insert text using this...
value += 'text'
but when I try and swap it out for a date function , it doesnt work.
value += getdate();
Can anyone point me in the right direction as I have been googling for ages and cant seem to find anything to help me undertand 
_________________
-----------
PHP/indy Game Developer - http://www.AbsoluteBreeze.co.uk |
 |
 |
TonyReid
Posts: 159
|
| Posted: 06/06/2006, 3:53 AM |
|
Ive worked it out... well at least to tie it to a field....
function PrintDate() {
var d = new Date();
var curr_date = d.getDate();
var curr_month = d.getMonth();
curr_month++;
if (curr_date < 10)
{
curr_date = "0" + curr_date;
}
if (curr_month < 10)
{
curr_month = "0" + curr_month;
}
var curr_year = d.getFullYear();
Bwip_Quote1.inception.value= curr_date + "/" + curr_month + "/" + curr_year;
}
</script>
In this case thetext field has an id of : inception and is on the Bwip_Quote1 form.
The issue I have is that i would like to make this work with any field - so I guess I need to use a dynamic variable in place of inception?
Any thoughts on the best way to do this?
_________________
-----------
PHP/indy Game Developer - http://www.AbsoluteBreeze.co.uk |
 |
 |
WKempees
|
| Posted: 06/06/2006, 4:21 AM |
|
Tony,
Cannot tell you straight away how, but check out the DatePicker and steal
the code from that.
Copy/Paste, still best practice
Walter
|
|
|
 |
TonyReid
Posts: 159
|
| Posted: 06/06/2006, 4:32 AM |
|
Hi Walter,
I did try to understand the date picker js but its a little too complex for me 
I'll keep trying though.
Tony
_________________
-----------
PHP/indy Game Developer - http://www.AbsoluteBreeze.co.uk |
 |
 |
TonyReid
Posts: 159
|
| Posted: 06/06/2006, 5:24 AM |
|
Thinking about it.....
What I need is to pass the variable to the function ( the onclick event) like this....
the ondblclick event:
PrintDate(inception)
code in html:
<script language="JavaScript">
function PrintDate(str) {
..........code here ........
Bwip_Quote1.str.value= curr_date + "/" + curr_month + "/" + curr_year;
}
</script>
Im sure thats what I need to do - but I cannot get it to work.
_________________
-----------
PHP/indy Game Developer - http://www.AbsoluteBreeze.co.uk |
 |
 |