php - trigger event on selected option -


this question has answer here:

is possible trigger event on selected option without submitting form?

  <h3 id="center" align="center">our site can provide info mantioned countries</h3>  <select style="padding:10px;margin-left: 550px;margin-top: 20px;">     <option name="india">india</option>     <option name="pakistan">pakistan</option>     <option name="us">united state</option>     <option name="uk">united kingdom</option> </select> 

you can't php (since it's server side language). use js/jquery that.

$(document).ready(function() {    $("#dropdown").change(function() {      alert("selection: " + $("option:selected", this).val() + ":" + $("option:selected", this).text());    });  });
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>  <h3 id="center" align="center">our site can provide info mantioned countries</h3>    <select id="dropdown" name="countries" style="padding:10px;margin-left: 550px;margin-top: 20px;">    <option value="india">india</option>    <option value="pakistan">pakistan</option>    <option value="us">united state</option>    <option value="uk">united kingdom</option>  </select>

also, name attribute select not option. check snippet markup changed.


Comments

Popular posts from this blog

c++ - QTextObjectInterface with Qml TextEdit (QQuickTextEdit) -

javascript - angular ng-required radio button not toggling required off in firefox 33, OK in chrome -

xcode - Swift Playground - Files are not readable -