php - onClick with string in parameter -
hey i'm in middle of making event calendar. each event in calendar respresented button , when click want pass variables it. right let me pass $id , reason neither of 2 string variables ($description , $title)
code onclick button , foreach loop information:
$event_day = $day_num . '.' . $month . '.' . $year; foreach ($eventarray $currentevent) { $result = $string->convert_timestamp_to_string($currentevent['start_date']); if ($result === $event_day) { $id = $currentevent['id']; $title = $currentevent['title']; $description = $currentevent['description']; $pagecontent .= '<input type="button" class="event" onclick="showdialog('.$id. $description. $title.')" value="' . $title . '"/>'; } }
here function that's supposed create dialog based on variables passed
var showdialog = function(id, description, title) { $("#dialog-modal").dialog({title:title});
};
i have tried seperating variables commas no luck.
thanks in advance.
i think weren't separating commas correctly. try this:
onclick="showdialog(\''.$id.'\',\''.$description.'\',\''.$title.'\')"
you may run issues if values contain single quotes.
another option might work better putting each value in data-
attribute, binding events jquery, , grabbing values data-
attributes in handler.
Comments
Post a Comment