Reputation: 37243
i have this code bellow and i have select options with $menucompare
values .
<script>
function displayVals() {
var singleValues = $("#menucompare").val();
$("#hiddenselect").attr("value", singleValues );
$("p").html("Procent of: " + singleValues);
}
$("select").change(displayVals);
displayVals();
</script>
<table width='100%' border='1' cellspacing='0' cellpadding='0'>
<th>weeks</th>
<th style="text-align: left; padding-left:5%;"><?php echo "<p></p>"; ?></th>
which i can get this value (Procent of: $menucompare) . but the problem is when i select one option , the value appears right when jquery is loading , and when jquery is finished loading it disapears this (Procent of: $menucompare) , of course the variable $menucompare commes with the right value.
so i want even when jquery finished loading this value stays in the table . hope can get some fix for this .
Upvotes: 0
Views: 71
Reputation: 9002
Try the following script instead:
<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);
}
</script>
Upvotes: 1