I know this is a frequent question but my case is different. Here is My code
PHP
if($mode == "All" || $mode == 'Offline')
{
echo "<label>By categories :</label>";
echo elgg_view('input/pulldown',array(
'options' => $options_values,
'internalname' => 'event_type',
'value' => get_input('event_type'),
'js' => 'onchange = set_filter('. $mode .')','internalid' => 'event_cat'
));
}
In same file i have written the script
Java script
function set_filter(mode){
var url = $('#event_cat option:selected').val();
alert(mode);
if ( mode == "Offline"){
var off_url = <?php $vars['url'] ?>"pg/event_calendar/filter/?&callback=true&event_type={url}&mode=offline";
alert(off_url);
}
}
The problem i am facing is i want to pass the "$mode" variable in "'js' => 'onchange = set_filter('. $mode .')'" function as a argument. But it saying undefined as alert in script. How to pass the variable ?