Difference between revisions of "Savefunc"

From SmartWiki
Jump to: navigation, search
Line 6: Line 6:
  
  
'''Example:'''
+
'''Example 1:'''
 
<pre>
 
<pre>
 
function savefunc()
 
function savefunc()
Line 13: Line 13:
 
RunAnotherFunction()
 
RunAnotherFunction()
 
do that
 
do that
return True
+
return true
 
}
 
}
 
</pre>
 
</pre>
  
 +
* Note that [[JavaScript]] is case sensitive.
  
 +
 +
'''Example 2:'''
 +
* The following sample [[JavaScript]] function will prompt the user to confirm if they really want to save the record.
 +
<pre>
 +
function savefunc()
 +
{
 +
var answer = confirm ("Do you really want to save this?")
 +
if (answer)
 +
  {
 +
  alert ("Consider it done")
 +
  return true
 +
  }
 +
else
 +
  {
 +
  alert ("Keep filling it in then")
 +
  return false
 +
  }
 +
}
 +
</pre>
 +
* ''The "return false" isn't strictly necessary. If the function does not return true then false is assumed.''
  
 
[[Category:JavaScript]]
 
[[Category:JavaScript]]

Revision as of 11:30, 31 July 2009

You can use savefunc to create a custom Browser Script that runs whenever a record is saved or submitted.

Instructions:


Example 1:

function savefunc()
{
do this
RunAnotherFunction()
do that
return true
}


Example 2:

  • The following sample JavaScript function will prompt the user to confirm if they really want to save the record.
function savefunc()
{
var answer = confirm ("Do you really want to save this?")
if (answer)
   {
   alert ("Consider it done")
   return true
   }
else
   {
   alert ("Keep filling it in then")
   return false
   }
}
  • The "return false" isn't strictly necessary. If the function does not return true then false is assumed.