Cannot retrieve value from html code to work with javascript functrion

بدون دیدگاه


I am struggling with how to allow the user to pick one of the following items from a drop down and taking that response into javascript. Once in javascript, I would like to run an if statement to print out a proper response then to the item they choose. Thanks in advance.

<body>

<h1>
What colors to use when fishing
</h1>

<p>Select one of these options that describe your day out on the waters. This will give you the best choice of colors to use for that kinda day.</p>

		<div id="DropDown">
        	<select  id="ddl">
	<option selected="selected" value=" ">Please Select</option>
	<option value="Sunny">Sunny</option>
	<option value="Cloudy">Cloudy</option>
	<option value="Raining">Raining</option>

</select>
    	</div>
    <div id="button">
    	<button onclick="goFish()">Go Fish!</button>
	</div>
    
<p id="printout"></p>


<script>
 
function goFish() {
var e = doucument.getElementById("ddl");
var weather = e.options[e.selectedIndex].value;
var lure;

    if (weather == "Sunny") 
    {
    lure = "Choose lures that are silver or gold";
    }
    
    else if (weather == "Cloudy") 
    {
   lure = "Choose lures that are UV or Flourescent";
    }
    
    else 
    {
    lure ="Choose lures that are darker like dark purple or black";
    }
    
    document.write(lure);
}
</script>

</body>



لینک منبع

  • نویسنده
    A-brand
  • تعداد بازدید
    18 views
0دیدگاه فرستاده شده است.
شما هم دیدگاه خود را بنویسید