I have five lists (select) that are populated with php / mysql and jquery. I use this script: http://bit.ly/3YTAXe
When I post my form and the new page appears, I redisplay my five list and I want my 5 lists will populate with the values posted.
I think I'd have to simulate the event "change" or something like that. I do not think my code can help (it's inside the smarty and many other things).
Does anyone can help me from the example code that is in the link above?
try .trigger()
$('#yourselect').val('yourvalue');
$('#yourselect').trigger('change');
It can also be chained into a single statement:
$('#yourselect').val('yourvalue').trigger('change');
a standard post action ask the server for a new page, which has no natural "memory" of the the form posted. So you have 3 basics options:
I prefer the 3rd option. jquery will send the form in ajax, and handle the response from the server inside the actual page. Of course, you have to "event.preventDefault" on the form submit button click (or in $('form').submit). Personally, I don't define any "action=" tag in forms supposed to be sent by $.post (i use a variable inside the $.post block).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With