I'm trying to make a dropdown in HTML, but I want to have it's default value to be determined by the value of a PHP variable. I wanted to do it with JavaScript, but I end up with the famous "Uncaught ReferenceError: $ is not defined" error :/.
PHP:
while(list($ArtikelID, $Type) = mysql_fetch_array($result))
{
$arid = $ArtikelID;
$te = $Type;
}
HTML + JS:
<form name="send" method="post" action="editartticlesdef.php">
articlenumber: </br>
<input readonly="readonly" name="ArticleID" value=<?php echo $arid ?>></br>
Type: </br>
<select name="Type">
<option value="Article">Article</option>
<option value="Code">Code</option>
<option value="News">News</option>
<option value="Project">Project</option>
</select></br>
<script>
document.getElementById("Type").selectedIndex = <?php echo '$te'; ?>;
</script>
</form>
I tried to place the script on other places on the page but had no success :/. I suspect the variable falls outside the scope, but I don't know how to get it back in :/.
<?php echo '$te'; ?>with'<?php echo $te; ?>'