passing a php variable to an onclick function in codeigniter

Sk8

New Member
I am creating a menu script that updates a div whenever it is being clicked. So in my scenerio what happens is, u search for a place, it brings back a list of places starting with similar letters, then u select one item(place) from the list which updates the div with the selected item.I am having troubles passing a php variable to my onclick function that would use the variable to retrieve the item from the database. Pls help here is my code (i am using codeingiter)look at the line with ------(in the model)if(count($query->result()) > 0){\[code\] $output = '<table><ul>'; foreach($query->result() as $venue_details){ if ($details){ $id = $venue_details->VenueID; $output .= '<tr><td><a href="http://stackoverflow.com/questions/3762867/#self" class="menulink" class==&{ns4class}; ----------- onClick="changeDiv(<?php echo $id; ?>)"> <strong>' . $venue_details->Name . '</strong><br/>'; $output .= ' '.$venue_details->Address1 .', '; $output .= $venue_details->Address2 .', '; $output .= $venue_details->City .', '; $output .=$venue_details->Postcode .', '; $output .=$venue_details->PhoneNumber .', '; $output .=$venue_details->URL .'</a></td></tr><hr/>'; } else { $output .= '<li>' . $venue_details->Name . '</li>'; } } $output .= '</ul></table>'; return $output;\[/code\]I am passing the variable here function changeDiv(venueID){ document.getElementById('venue_description').innerHTML=venueID;}
 
Back
Top