Results 1 to 4 of 4

Thread: onchange Event for birthdate

  1. #1
    lenz1979 is offline Sugar Community Member
    Join Date
    Jun 2009
    Posts
    68

    Default onchange Event for birthdate

    Hello!

    I need to implement an onchange event for the birthdate field in the contacts.

    using sugar 5.2 and the following editveidefs.php part:

    PHP Code:
            3 => 
            array (
              
    => 
              array (
                
    'name' => 'birthdate',
                
    'label' => 'LBL_BIRTHDATE',
                
    'tabindex' => '5',
                
    'displayParams' => 
                array (
                  
    'javascript' => 'onchange="alert(this.value);"',
                ),
              ),
              
    => NULL,
            ), 
    But it does not work.

    maybe you can help what i have to change.

    thanks

  2. #2
    lenz1979 is offline Sugar Community Member
    Join Date
    Jun 2009
    Posts
    68

    Default Re: onchange Event for birthdate

    found a solution.

    had to add "{{$displayParams.javascript}}" in the EditView.tpl of the Datetime field

  3. #3
    cactusJoe is offline Sugar Community Member
    Join Date
    Jul 2009
    Location
    Cape Town, South Africa
    Posts
    25

    Default Re: onchange Event for birthdate

    Rather than editing the templates, I add the onchange event in javascript after the page has loaded

    PHP Code:
    document.getElementById('fieldname').onchange = function(){ myFunction(); }; 
    Note: This is javascript, not PHP code as the heading says

  4. #4
    sijojohnson is offline Member
    Join Date
    Nov 2010
    Posts
    6

    Default Re: onchange Event for birthdate

    Hi lenz1979, try this. This worked very well for me. If you need to call a function from another file you can include that file in the editviewdes.php file. The external file should be added in the templateMeta array

    'javascript' => '<script type="text/javascript" src="modules/Contacts/Contacts.js"></script>
    0 =>
    array (
    'name' => 'birthdate',
    'label' => 'LBL_BIRTHDATE',
    'tabindex' => '5',
    'displayParams' =>
    array (
    'field' =>
    array (
    'onChange' => 'alert(\’Happy Birthday\’);',
    ),
    ),
    ),
    Last edited by sijojohnson; 2011-07-08 at 04:44 AM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. onchange event for dropdown
    By vijay9948 in forum Help
    Replies: 7
    Last Post: 2009-09-11, 04:54 AM
  2. Dropdown onchange event
    By prasannagowri in forum Classifieds
    Replies: 17
    Last Post: 2009-05-20, 07:26 AM
  3. onchange event for dropdown list
    By vijay9948 in forum Developer Help
    Replies: 3
    Last Post: 2009-04-18, 10:42 AM
  4. onchange event for dropdown list
    By vijay9948 in forum Developer Tutorials
    Replies: 0
    Last Post: 2009-01-16, 02:57 AM
  5. populate multiple fields with an onchange event
    By danrweki in forum Developer Help
    Replies: 5
    Last Post: 2008-08-08, 12:38 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •