Unable to get the correct value from the variable in side the function.
Here is my code and always i am getting id as "two", i need the correct value that i passed to change function.
<script type="text/javascript">
<?php
$val='';
global $val;
?>
function change(val){
<?php //global $val;?>
if (val=='one') {
<?php $val='one';?>
}
if (val=='two') {
<?php $val='two';?>
}
}
</script>
<input type="button" onclick="change('one');" value="Change">
<div id="<?php echo $val;?>">