This topic is locked

Auto Insert Date upon Checkbox

12/22/2008 5:54:21 AM
PHPRunner General questions
S
swanside author

I am trying to get this to work, But, guess what, I cant do it.
Can anybody suggest the correct syntax for this please?
Thanks

<script>

document.forms.editform.value_Invoice_Printed.onchange=function()

{

document.forms.editform.value_Invoice_Printing_Date.value=now()

}

</SCRIPT>

</BODY></HTML>


I can do it using the events page, but it has to be saved before the date shows up.

T
thesofa 12/22/2008

something along the lines of an before record saved event will do it, so

if ($values["Invoice_Printed"]!=$oldvalues["Invoice_Printed"])

$values["Invoice_Printing_Date"]=now();
S
swanside author 12/22/2008

That works if I put it the events before record updated, but I really wanted it to happen on the fly, so as soon as the checkbox is ticked, the script will put in the date before the save button is pressed.

T
thesofa 12/22/2008

sorry mate, I have no idea how to do that, have you tried looking for javascript or ajax snippets on the web?

S
swanside author 12/22/2008

Not yet, but will look later, got to take the wife christmas shopping now. No time to play.
Thanks for your help.

J
Jane 12/22/2008

Hi,
use JavaScript date/time functions for this purpose:

http://www.w3schools.com/jsref/jsref_obj_date.asp

S
swanside author 12/22/2008

Thanks Jane
I tried this

<script>

document.forms.editform.value_Invoice_Printed.onchange=function()

{

document.forms.editform.value_Invoice_Printing_Date.value=document.write(Date());

}

</SCRIPT>


But it opens a new page and puts the day date month and year on a new page?

S
swanside author 12/24/2008

I have tried this as well

<script>

document.forms.editform.value_Invoice_Printed.onchange=function()

{

document.forms.editform.value_Invoice_Printing_Date.value=document.write(Date(now));

}

</SCRIPT>


But I still can not get it to work,
Is there a diferent syntax for this, as sometimes it displays
Monday, 22 December 2008
and not 22 December 2008 in the correct boxes?

J
Jane 12/24/2008

Hi,
here is just a sample:

var d=new Date();

document.forms.editform.value_Invoice_Printing_Date.value=""+d.getDate()+"/"+(d.getMonth()+1)+"/"+d.getFullYear();

S
swanside author 12/24/2008

Thanks Jane.
Put this in

<script>

document.forms.editform.value_Invoice_Printed.onchange=function()

{

var d=new Date();

document.forms.editform.value_Invoice_Printing_Date.value=""+d.getDate()+"/"+(d.getMonth()+1)+"/"+d.getFullYear();

}

</SCRIPT>

</BODY></HTML>


ANd still wont work.
I have a page with a check box for Invoice_Printed

Below it I have the Datepicker with calender, What I want is when the checkbox is ticked, the date gets entered without having to go and save the page first, but I still having trouble
Thanks again
Paul.

J
Jane 12/24/2008

It's difficult to tell you what's happening without seeing actual files.
Please publish your project on Demo Account and open a ticket at http://support.xlinesoft.com sending a URL to your pages along with instructions on reproducing this error.