I am using codeigniter 3. Below is the code of the view page, where data inside the $row->poll_question; is coming from the database. Thus, the different values coming inside this variable are echoed on a page called voting.php. And just beside this variable, there is a button called View Poll. Now, on clicking this button I want to pass the data of this php variable to javascript section. And simply alert and check in javascript. Please help. I have pasted the code I tried.
voting.php
<h3 class="val" id="val" style="color:rgb(158, 158, 158);font-family:
arial;margin-top: 2%;" ><?php echo $row->poll_question; ?></h3>
</td>
<td>
<a class="btn btn-lg btn-primary view_button" id="view_button"
style="margin-left: 18%;padding:10%;border-radius: 10px;"
onclick="fetch_val(<?php echo $row->poll_question ?>)">View Poll</a>
Javascript
function fetch_val(val)
{
alert(val);
}