Reputation: 9439
I have this code to append the input panel #yearPanel
after the select box #before
changed.
$("#before").change(function() {
var selected = $('#before option:selected').text();
if(selected == bankShowYear) {
$(yearPanel).insertAfter("#yearAnchor");
var value = $("#yearHiden").val();
$("#year").val(value);
} else {
$("#yearPanel").remove();
}
});
I want to keep the input value of #year
in #yearPanel
after submitting by PHP. I tried to store the value in #yearHidden
and assign it to #year
after all the input are rendered but it doesn't work.
How to keep the input value?
Upvotes: 0
Views: 102
Reputation:
Try this:
$("#before").change(function() {
var selected = $('#before option:selected').text();
if(selected == bankShowYear) {
$(yearPanel).insertAfter("#yearAnchor");
var value = $("#yearHiden").val();
$("#year").val(value).attr('name', 'year');
} else {
$("#yearPanel").remove();
}
});
Then, on your next page:
$("#year").value(<?php echo $_REQUEST['year']?>);
OR
<input id="year" value="<?php echo $_REQUEST['year']?>" />
Upvotes: 1
Reputation: 1265
You need to pass the value to PHP via a hidden field and PHP will have to render it on the next page. In other words the value needs to go from the client-side to the server-side and back to the client-side.
Upvotes: 0
Reputation: 6332
your input needs a name attribute in order for it to be passed along to your serverside php script
Upvotes: 1