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; ?>
</div>
<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') ?>
<?php
echo button_to_function('Add',
update_element_function('notifiers',
array(
'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 !
