javascript - jQuery change the value of a variable on dropdown select from database -


i working on project stuck @ point right now. need change value of div live on select of dropdown using jquery.

example:

i want this:-

<select name=""> <option value="10">10 clicks</option> <option value="20">20 clicks</option> <option value="30">30 clicks</option> <option value="40">40 clicks</option> </select>  <div id="chpln">clicks: 0 clicks</div> 

when select option 1 value displayed in place of 0 in div live. problem select value fetches data database not understanding how it.

example:

<select name="" id="pln" class="select-box" style="margin-top: -40px;"  />   <?php while($ac_fetch = mysql_fetch_array($qur_ac)){ ?>   <option value="<?php echo $ac_fetch['adclk_clicks']; ?>"><?php echo $ac_fetch['adclk_clicks']; ?> clicks</option>   <?php } ?> </select> 

jquery used currently:-

$(document).ready(function(){     $("#pln").click(function(){         $("#chpln").text("plan: <?php echo $ac_fetch['adclk_clicks']; ?> secs");     }); }); 

this jquery changing value getting first value of database i.e., 10. when choose different option still displays first value database i.e., 10 while should display second value 20. please me. fiddle appreciated.

click wrong event selection box can utilize change event result.

$(document).ready(function(){     $("#pln").change(function(){         $("#chpln").text("plan: "+$(this).val()+" secs");     }); }); 

Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -