I have an php array that is generated by server-side code. I want to show the array value in my input field after user pick an option from my dropdown menu. Please see my code:
$(document).ready(function(){
$('select[name="job_number"]').change (function () {
var selectedVal = $(this).val();
var test="<?php echo $JNarray['selectedVal'];?>"; //where the problem is
$('input[name="project"]').val(test);
//I want show value1 to value 3 in my input field when user picks
//an option from my dropdown menu.
});
<?php
$JNarray['job1']=value1;
$JNarray['job2']=value2;
$JNarray['job3']=value3;
?>
<form action='project_manager' method='post'>
<input type='text' name='project' value='show value1 to value3 when user picks an option' />
<select name='job_number'>
<option value='job1'>job1</option>
<option value='job2'>job2</option>
<option value='job3'>job3</option>
</select>
</form>
Any thoughts? Thanks for the help!