Hi, I'd playing with JavaScipt nowadays. I'm trying to display the selected value in a dropdown list (those values are the array elements).
Here is what I've tried so far:
<html>
<head>
<script type="text/javascript">
window.onload = function() {
var artists_arr = new Array();
artists_arr[0] = "The Beatles";
artists_arr[1] = "The Doors";
artists_arr[2] = "The Cascades";
var Artists = document.getElementById("Artists");
for (i=0;i<artists_arr.length;i++)
{
var Entry = document.createElement("option");
Entry.text = artists_arr[i].toUpperCase();
Artists.add(Entry ,null);
}
var strUser = Artists.options[Artists.selectedIndex].text;
}
</script>
<title>Artists Page</title>
</head>
<body>
<Form method="POST" action="artists.php">
Select your favorite artist: <select id="Artists" name="artists"></select><br />
<input type="submit" name="submit" value="Ok" />
</Form>
<?php if(!isset($_POST['submit'])){
} else{
echo "Your favorie artist is: ";
}
?>
</html>
In the echo "Your favorie artist is: ";
I'd like to display the selected value. I need your help. Thanks I would appreciate it...