Difference between revisions of "Using a Check Box to run a JavaScript"

From SmartWiki
Jump to: navigation, search
Line 17: Line 17:
 
* The ''document.frmevent.cf_123456[1].checked=false'' line unchecks the check box if you wish to have the check box behave like a button.
 
* The ''document.frmevent.cf_123456[1].checked=false'' line unchecks the check box if you wish to have the check box behave like a button.
  
'''Note''': at level one use ''document.form1'' instead of ''document.frmevent''
+
'''Note''':  
 +
*At Level one use ''document.form1'' instead of ''document.frmevent''
 +
*On a tab use ''document.frmedit'' instead of ''document.frmevent''
  
  

Revision as of 13:18, 23 March 2009

You can use a Check Box to run a JavaScript, such that the check box works much like a button on the page to run the script. This is done using a combination of the HTML Tag and a browser script to create the action event. One of the lines in the script can also un-check the check box.

In the HTML Tag field on the Check Box Custom Field you would put an OnClick event:

onclick="runthis()"

Then in the browser script Custom Field you would define the JavaScript function:

function runthis()
{
--enter whatever the script should do here--
document.frmevent.cf_123456[1].checked=false;
}

where "123456" is the field ID of the Check Box.

  • The document.frmevent.cf_123456[1].checked=false line unchecks the check box if you wish to have the check box behave like a button.

Note:

  • At Level one use document.form1 instead of document.frmevent
  • On a tab use document.frmedit instead of document.frmevent


See Also: Using an HTML Tag to Create Action Events