Jump to content

Javascript: Difference between revisions

From NusaATK
Samk (talk | contribs)
New page: {{howto|Medium|Sam Kapilivsky}} This howto demonstrates some Javascript features that are built into ATK. == Hiding and attribute or relation depending on the value of another attrib...
 
Samk (talk | contribs)
Line 3: Line 3:
This howto demonstrates some Javascript features that are built into ATK.
This howto demonstrates some Javascript features that are built into ATK.


== Hiding and attribute or relation depending on the value of another attribute  ==
== Hiding or showing an attribute or relation depending on the value of another attribute  ==


If you have an attribute that should hide or show depending on the value of another attribute, you can use the following construct:
If you have an attribute that should hide or show depending on the value of another attribute, you can use the following construct:


<syntaxhighlight lang="php">
<syntaxhighlight lang="php">
$attr = &$this->add(new atkListAttribute(........  
&$this->add(new atkAttribute('myAttribute',........
$attr->addOnChangeHandler("if (newvalue=='no') { hideAttrib('colorpickthing'); }");  
$attr = &$this->add(new atkBoolAttribute(........  
$attr->addOnChangeHandler("if (newvalue=='no') { hideAttrib('myAttribute'); } else { showAttrib('myAttribute'); }");  
</syntaxhighlight>
</syntaxhighlight>

Revision as of 22:00, 14 November 2008

ATK Howto: Javascript

Complexity: Medium
Author: Sam Kapilivsky

List of other Howto's

This howto demonstrates some Javascript features that are built into ATK.

Hiding or showing an attribute or relation depending on the value of another attribute

If you have an attribute that should hide or show depending on the value of another attribute, you can use the following construct:

&$this->add(new atkAttribute('myAttribute',........ 
$attr = &$this->add(new atkBoolAttribute(........ 
$attr->addOnChangeHandler("if (newvalue=='no') { hideAttrib('myAttribute'); } else { showAttrib('myAttribute'); }");