Reputation: 169
I have the follow ajax code (using jquery and x-editable plugin) for updating a select field.
<a href="#" id="days" data-pk="<?php echo $id; ?>" data-url="post.php" data-title="days" data-type="select" class="editable editable-click">
<?php
if (!empty($days)) { echo $days;
} else { echo "Please Select";
}
?>
</a>
<script>
$(function() {
$('#days').editable({
source : [{
value : '',
text : 'Please select'
}, {
value : '1',
text : '1 day'
}, {
value : '30',
text : '1 month'
}, {
value : '360',
text : '1 year'
}]
});
});
</script>
After field is updated, it displays the select text '1 day', '1 month' or '1 year' as the way I want.
But after a page refresh, it displays the select value, as '1', '30' or '360'.
What I need to do display the text from select?
Thank you!!!
Upvotes: 0
Views: 472
Reputation: 414
To remember and display the option user selects you need to store it in session variable in ajax call.
Sample high level example:
$.ajax{(
url:../store.php,
data: optionselected:selected,
method:post
});
In store.php
set it to a session variable and use this for display while user reloads page.
Upvotes: 1