This topic is locked

On Field Value Change Event

8/26/2008 4:20:43 PM
ASPRunnerPro General questions
S
savin author

I was wondering if there was a way to have an event that happens when the contents of a field are changed? The reason would be that some fields might be calculated. Obviously it could be done in the ASP code, but it would be cleaner if it was an event in ASPRunner. For example:
Lets say I have a table that has an invoice number, an item number, a quantity and a unit price. InvNum, ItemNum, Quantity, UnitPrice. I could easily add in the SQL Quantity * UnitPrice as Price and the extra field is visible. But on an edit or add screen I would like to have the field recalc on a change either UnitPrice or Quantity. So what I need is ASP code that fires as soon as a person moves to another field. Easy ... But it would be nice to have an ASPRunner Event I could use. (assuming it doesn't already have one and I'm being incredabily thick LOL)
BTW ... is their the conept of a hidden field? I can pick the field for the screen but its not visible? (useful for calculations)
BTW ... very easy to use product!!!

J
Jane 8/27/2008

Hi,
there are two ways:

  1. use Before record added/updated events on the Events tab to calculate values and fill field.

    Here is a sample:
    dict("FieldName1") = dict("FieldName2")*dict("FieldName3")


2. use JavaScript code on the Visual Editor tab (in HTML mode) to calculate new values on the fly.

Here is a sample:

{literal}

<script>

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

{

document.forms.editform.value_FieldName1.value=document.forms.editform.value_Fie

ldName2.value*document.forms.editform.value_FieldName3.value;

}

</script>

{/literal}

M
michaelmac 10/15/2008

Hey Jane,
I think I understand here, but my problem is similar to the poster problem. I have "two" dates on my Add form. When the user selects the "Start" date from the calendar, I need to have the next field in "End" date to become the "Start" date that was entered "First"... I mean they can still change it, but it will change it when the get to that calendar. What I am tried to do is follow your example up above, but I keep getting a "document.forms error". My field names are "start_date" and "end_date" and I am just adding them to the Add page. I do not want to do this with an event, I thought I was following your example, but guess I did something wrong. Can you help?
Thanks
Mike

J
Jane 10/16/2008

Mike,
It's difficult to tell you what's happening without seeing actual files.
Please publish your project on Demo Account and send to support@xlinesoft.com a URL to your pages along with instructions on reproducing this error.

I'll find what's wrong with your project inspecting it at Demo account site.