How can I trigger the onChange when the page loads.
For instance say that the colour red has been inserted in to mysql and when I return to this page the colour red is inserted back in to the drop down menu, how can I get javascript to trigger this when the page loads so that the messages are displayed without having to trigger this function by using the drop down menu?
<script type="text/javascript">
function ShowItem(){
var Index = document.getElementById("mycolor").selectedIndex;
chosenColour = document.getElementById("mycolor").options[Index].text;
document.getElementById("Msg1").innerHTML = "You have chosen the colour " + chosenColour
document.getElementById("Msg2").innerHTML = "I like the colour " + chosenColour
document.getElementById("Msg3").innerHTML = chosenColour + " is a nice colour"
}
</script>
<select id="mycolor" name="mycolor" onchange="ShowItem()">
<option value="Red">Red</option>
<option value="Green">Green</option>
<option value="Blue">Blue</option>
<option value="White">White</option>
</select>
<BR><BR>
<span id="Msg1"></span>
<BR><BR>
<span id="Msg2"></span>
<BR><BR>
<span id="Msg3"></span>
For instance say that the colour red has been inserted in to mysql and when I return to this page the colour red is inserted back in to the drop down menu, how can I get javascript to trigger this when the page loads so that the messages are displayed without having to trigger this function by using the drop down menu?
<script type="text/javascript">
function ShowItem(){
var Index = document.getElementById("mycolor").selectedIndex;
chosenColour = document.getElementById("mycolor").options[Index].text;
document.getElementById("Msg1").innerHTML = "You have chosen the colour " + chosenColour
document.getElementById("Msg2").innerHTML = "I like the colour " + chosenColour
document.getElementById("Msg3").innerHTML = chosenColour + " is a nice colour"
}
</script>
<select id="mycolor" name="mycolor" onchange="ShowItem()">
<option value="Red">Red</option>
<option value="Green">Green</option>
<option value="Blue">Blue</option>
<option value="White">White</option>
</select>
<BR><BR>
<span id="Msg1"></span>
<BR><BR>
<span id="Msg2"></span>
<BR><BR>
<span id="Msg3"></span>