This content has been marked as final.
Show 6 replies
-
1. Re: Insert Script Object?
John.Kordas Jul 10, 2006 3:20 PM (in response to John.Kordas)Why is it that after you post a message you go back to the problem and play a little bit more and work out the answer?
I change the script object slightly so as to not confuse myself but still called it Hello:
function Welcome()
{
app.alert("Hello World")
}
Then on the action mouse up I used:
form1.variables.hello.Welcome();
And what do you know it all works. -
2. Re: Insert Script Object?
John.Kordas Jul 10, 2006 4:06 PM (in response to John.Kordas)Back to square one.
Using the logic above if I make a script object and call it setTotals with the following script in place:
function Totals(){
var totalval = form1.costs.spei1.rawValue + form1.costs.spei2.rawValue;
if (totalval == 0 || totalval == null || totalval == "")
{
this.rawValue = "";
}
else
{
this.rawValue = totalval;
}}
Then in the field that is to display the totals I put the following script under calculate:
form1.variables.setTotals.Totals();
When I type a figure into spei1 or spei2 nothing happens.
Am I missing something? -
3. Re: Insert Script Object?
(Steve_Woodruff) Jul 10, 2006 11:13 PM (in response to John.Kordas)Hi,
If you're using thethispointer within a scripting object, it points to the scripting object itself, not to a form variable!
Try this one:
function Totals(obj){
var totalval = form1.costs.spei1.rawValue + form1.costs.spei2.rawValue;
if (totalval == 0 || totalval == null || totalval == "")
obj.rawValue = "";
else
obj.rawValue = totalval;
}
...then call this function using:
form1.variables.setTotals.Totals(this);
Here you go. :-)
Regards,
Steve -
4. Re: Insert Script Object?
John.Kordas Jul 11, 2006 4:24 PM (in response to John.Kordas)Thanks Steve,
It works without a hitch. Im still getting my head around JavaScript and 2 weeks, 6 hours a day of reading and testing and reading is slowly getting clearer I think.
Just to make sure Im getting this clear in my head. The way I had the script before was when it was applied to the field that showed the value it was referring to this as the field itself. So it worked not worries because it was point to the itself.
When I tried to apply the same script in a script object field (variables) that the whole documents can reference it was only in as a variable. The line form1.variables.setTotals.Totals(); did not do anything because it did not see the totals as a function and refer to it, and as a result nothing would appear in the filed. By adding obj to the script it tells the form that its an object and the objects formula is spei1 + spei2. This now means that the script can be applied to any filed and that is where form1.variables.setTotals.Totals(this); comes in. It tells the filed apply the object (Totals [spei1 + spei2] ) to this filed.
Does this mean that any script placed in the Variables field needs to be referred to as objects?
The reason I was taking this approach was to resolve a problem posted earlier.
I thought by having the script as a script object that was applied to the document rather than the field it would update the other fields that refer to it. Which I now realize will not happen. Could you suggest a conditional statement that I could put in to:
If special item 1 = $12.00 the result in the total = $12.00. If I then click on one of the fields in the special column say in Monday for example the result should be $12.00. If I then decide to enter another $12.00 in special item 2 the total will now be $24.00 but the Monday result will still say $12.00.
Is there a way to have it check that it the figure which may appear in the Special column, to update that result as well?
Should I be look at a message box instead telling the user there is a difference and for them to re-click on the Monday field to update it?
Any suggestions would be appreciated.
Regards, John. -
5. Re: Insert Script Object?
(Stefanie_Mueller) Aug 22, 2006 6:05 AM (in response to John.Kordas)Hello, I tried to undestand your messages - but still have a general problem in understanding the issue.
I would like to define the following function which I want to use on 20 textfields. But I don´t know where to place the definition - and how to define the path on the exit-event in each textfield.
function fertig ()
{
if (this.rawValue != null)
{
this.ui.oneOfChild.border.presence = "hidden";
} else {
this.ui.oneOfChild.border.presence = "visible";
}}
Can you help with this?
Stefanie -
6. Re: Insert Script Object?
(Steve_Woodruff) Aug 25, 2006 3:25 AM (in response to John.Kordas)Stefanie,
What do you want to accomplish? Do you want to use the methodfertigwith the exit-event of multiple form fields?
Steve

