Si Cranmer
|
| Posted: 04/07/2002, 11:28 AM |
|
I have a problem trying to populate a field with a calulated value from another.
ie. Below is my code. I am trying to update field "WeekNo" with the difference in weeks from the hidden field "YrStartDt" and the changing value from "LastODOUpd".
Cheers
Si.
<html>
<head>
<script language="JavaScript">
//--
//--Calculate the week number
//--
function FiscalWeekNumber(earlyDate,laterDate){
//-- Returns number of days between two date objects.
var earlySecs=earlyDate.getTime()
var laterSecs=laterDate.getTime()
return Math.floor (((((((laterSecs-earlySecs)/1000)/60)/60)/24)/7)+1)
}
</script>
</head>
<body>
<center>
<table>
<tr>
<td valign="top">
<form method="POST" action="MileageUpd_Record.php" name="MileageUpd">
<table class="FormTABLE">
<tr>
<td class="FieldCaptionTD"><font class="FieldCaptionFONT">Entry Date</font></td>
<td class="DataTD"><font class="DataFONT"><input type="text" name="LastODOUpd" maxlength="" value="" size="" onclick="document.MileageUpd.WeekNo.value=FiscalWeekNumber(document.MileageUpd.YrStartDt.value,document.MileageUpd.LastODOUpd.value)"> </font></td>
</tr>
<tr>
<td class="FieldCaptionTD"><font class="FieldCaptionFONT">Week Number</font></td>
<td class="DataTD"><input type="text" name="WeekNo" maxlength="" value="" size=""></td>
</tr>
<tr>
<td colspan="2" align="right">
<!-- *** Buttons *** -->
<input type="hidden" value="update" name="FormAction"/>
<input type="submit" value="Update" onclick="document.MileageUpd.FormAction.value = 'update';"/>
<input type="submit" value="Cancel" onclick="document.MileageUpd.FormAction.value = 'cancel';"/>
<input type="hidden" name="FormName" value="MileageUpd"/>
<input type="hidden" name="PK_FleetNo" value="C00011"/>
<input type="hidden" name="FleetNo" value="C00011"/>
<input type="hidden" name="YrStartDt" value="20-06-2001"/>
<input type="hidden" name="VehicleUsage" value="CA"/>
</td>
</tr>
</table>
</form>
</td>
</tr>
</table>
<!----->
</center>
</body>
</html>
|
|
|
 |
Alex Alexapolsky
|
| Posted: 04/08/2002, 2:47 AM |
|
CC automatically creates variables for form/database fields.
They contain field values that you can feel free to change.
"fld" is a standard prefix for cc field variable. For instance
if field name is price then corresponding cc variable is named fldprice.
You can manipulate them through events.
In your case you should use Form properties/Events/Before Show event, e.g.
fldmydate = myfunction(myflddate)
|
|
|
 |
Si Cranmer
|
| Posted: 04/09/2002, 2:43 AM |
|
I know all that and unfortunately you have not understood what I want. I want the field "WeekNo" to change THE MOMENT the user changes the value of the "LastODOUpd" field (ie via javascript) NOT once they have posted it.
SOMEONE PLEASE HELP ME!
|
|
|
 |
Nicole
|
| Posted: 04/09/2002, 2:59 AM |
|
Hello,
I understand from you message the code doesn't work. Do you get anu javascript errors? Which ones?
|
|
|
 |
Si Cranmer
|
| Posted: 04/10/2002, 5:42 AM |
|
The meseage is
Line: 9
Char: 1
Error: Object Doesn't support this property or method
By the way, I included all of the code in the original mail so you can just cust and paste into a file to test if need be.
TA
Si.
|
|
|
 |
Si
|
| Posted: 04/12/2002, 1:58 PM |
|
Please, anyone !
|
|
|
 |
Si Cranmer
|
| Posted: 04/17/2002, 5:34 AM |
|
Please, please, please... HELP!
|
|
|
 |