i have this code , and im currently getting the 'mytablevalues' but i wonder if i can get 'myvalues' , i mean only the text of the select.
<form id="aform" method="post"> <select id="menucompare" name ="menucompare" size="1"> <option value="nothing" <?php if ($menucompare == "nothing") { echo " selected='selected'"; } ?>>Select one</option> <option value="mytablevalue1" <?php if ($menucompare == "mytablevalue1") { echo " selected='selected'"; } ?> >myvalue1</option> <option value="mytablevalue2" <?php if ($menucompare == "mytablevalue2") { echo " selected='selected'"; } ?> >myvalue2</option> <option value="mytablevalue3" <?php if ($menucompare == "mytablevalue3") { echo " selected='selected'"; } ?> >myvalue3</option> <option value="mytablevalue4" <?php if ($menucompare == "mytablevalue4") { echo " selected='selected'"; } ?> >myvalue4</option> </select> <input type="hidden" name="hidevalue" value="<?php echo $menucompare ; ?>" /> <noscript><input type="submit" value="Submit"></noscript> </form> <script type="text/javascript"> $(document).ready(function(){ $("select").change(function() { displayVals(); }); displayVals(); }); function displayVals() { var singleValues = $("#menucompare").val(); $("#hiddenselect").val(singleValues); $("p").html("Procent of : " + singleValues); } and also im having trouble with default value (nothing). any suggest !
EDIT . i get it to work like that
<script type="text/javascript"> $(document).ready(function(){ $("select").change(function() { displayVals(); }); displayVals(); }); function displayVals() { var singleValues = $("select option:selected").text(); $("#hiddenselect").val(singleValues); $("p").html("Procent of :    " + singleValues); } </script>