This forum is in READ-ONLY mode.
You can look around, but if you want to ask a new question, please use Stack Overflow.

update_element_function with a JS function's return value

Forum to discuss ExtJS and other JS plugins

update_element_function with a JS function's return value

by Archaon » Tue Feb 17, 2009 12:45 pm


I am trying to create a button which get values from two input (text type) and then insert the concatenated strings in a div.

I made the following code block :
Code: Select all
<?php echo javascript_tag("
   function getNotifierNameAndTitle()
      alert($('newNotifierName').value.concat(', ').concat($('newNotifierTitle').value)).concat('<br />');
      return $('newNotifierName').value.concat(', ').concat($('newNotifierTitle').value).concat('<br />');
") ?>

   <div id='notifiers' style="height: 100px; width:600px; overflow:auto;">
      <?php foreach ($notifiers as $notifier): ?>
         <?php echo checkbox_tag('notifiers_selection[]', $notifier->getId()) ?>
         <?php echo $notifier->getName() . ", " . $notifier->getTitle() ?>
         <br />
      <?php endforeach; ?>

   <label for="newNotifierName">Notifier's name:</label>
     <?php echo input_tag('newNotifierName', 'Name') ?>
   <label for="newNotifierTitle">Notifier's title:</label>
    <?php echo input_tag('newNotifierTitle', 'Title') ?>

       echo button_to_function('Add',
               'position' => 'after',
                 'content'  =>  "<script>getNotifierNameAndTitle()</script>",

In practice, the JS function is called, the alert is processed but the JS function's return value never appears in my div.

Thanks for the help !
Junior Member
Posts: 3
Joined: Tue Feb 17, 2009 12:28 pm