i have a JavaScript here embedded in a PHP script "echo". when i use the document.getElementById('list_subjects').selectedIndex
in alert box it gives the result but when i use it in a php array variable. it says undefined index. i did (int)$index
to convert it a integer but its output only is always zero. whats the problem here? Thank You!
<?php
echo "<script> function subject_name(){" . ($index = "(document.getElementById('list_subjects').selectedIndex)") . ";document.getElementById('subj_name').innerHTML = '" . ($list_options_name[(int)$index]) . "';} </script>";
?>