jquery - Dropdown combination in javascript -


i new javascript. trying make drop-down combination work project apparently not working. can please check error in code.

this html code.

<select id="chartselect" onchange="changechart(this.value);">    <option value="line">line chart</option>    <option value="pie">pie chart</option>    <option value="map">choropleth map</option> </select> <select id="dataselect" onchange="changedata(this.value);">    <option value="house">house data</option>    <option value="toilet">toilet data</option> </select> 

and javascript portion;

function changechart(ele){    var value = chartselect.options[chartselect.selectedindex].value;    if (value==="pie"){       var datatype = dataselect.options[dataselect.selectedindex].value;       if (datatype === "house"){          alert("this pie chart(house)");       }       if (datatype === "toilet"){          alert("this pie chart(toilet)");       }    }    if(value=="line"){       var datatype = dataselect.options[dataselect.selectedindex].value;       if(datatype == "house"){          alert("this line chart(house)");       }       if (datatype == "toilet"){          alert("this line chart(toilet)");       }    } }; 

this link jsfiddle.

http://jsfiddle.net/rfxtk/

you have 1 more error in changedata() function not defined, , 1 more thing changechart(this.value); there no use of this.value in side function, have refined code error free.fiddle demo

function changechart() {             var value = chartselect.options[chartselect.selectedindex].value;             if (value == "pie") {                 var datatype = dataselect.options[dataselect.selectedindex].value;                 if (datatype == "house") {                     alert("aakarshan")                 }                 if (datatype == "toilet") {                     alert("dhakal")                 }              }              if (value == "line") {                 var datatype = dataselect.options[dataselect.selectedindex].value;                 if (datatype == "house") {                     alert("bivav")                 }                 if (datatype == "toilet") {                     alert("satyal")                 }              }          } 

Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -