I have HTML <select>
tag ID. I need to track with javascript, which option is selected
My html <select>
id:
<select id="<?php echo $userArray[$key]["userID"]?>">
My javascript code:
<script type="text/javascript">
$(document).ready(function(){
$('#selectionButton').click(function(){
var selectedValue = $("#<?php echo json_encode($userArray[$key]['userID']);?>").val();
window.alert(selectedValue);
});
});
How to use PHP array as HTML id in javascript?