I want to get the user's selected option value as a javaScript alert. But my alert is not working.
Here is my HTML code.
<select id="formats_id" name="aformats" >
<option value="<?php echo $jrowa2['formats']; ?>" onchange="showshowFormat(this.value)" ><?php echo $jrowa2['formats']; ?></option>
<?php foreach($formats3 as $v3){ ?>
<?php if($v3 !== $jrowa2['formats']) { ?>
<option value="<?php echo $v3; ?>"><?php echo $v3; ?></option>
<?php } ?>
<?php } ?>
</select>
Here is my javaScript code.
function showshowFormat(){
var $this = $(this); // assign $(this) to $this
var formats_value = $this.val();
alert(formats_value);
}