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.


What colors to use when fishing

<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>

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

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";
    lure ="Choose lures that are darker like dark purple or black";


لینک منبع

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