The data is still there since the browser does a cache of the form
info, but dynamically created elements do not get cached in the same
way, unfortunately.

I haven't tried this before, but one thing you can try is to have a
hidden input in your form, and the purpose of this is to store the
number of fields you have dynamically generated. Every time you add/
remove fields, you update this number. Then on page load, you populate
the form with this many extra fields. However, since I haven't tried
this before, I'm guessing that the new fields will not be pre-
populated like the other static fields....
I don't think there really is any good workaround for that except to
constantly save the form data to a cookie or to a database (via AJAX).

Another is to use the onbeforeunload event handler which is triggered
right before a page is left/re-loaded, and a prompt will be given,
which can be canceled and the refresh will not occur. (Google Groups
uses this when you type a message and try to leave/refresh the page.)
Just do a Google search on this and you'll find out lots about it.

On Jul 16, 12:46 pm, Terry <tgshan...@excite.com> wrote:
> Hi, I have a moderate level of experience with javascript, and a good
> oo background. So, when I tried jquery I'm really liking it.
>
> I have a requirement to add input fields dynamically to the form since
> I don't know ahead of time how many entries the user may request. I
> was able to implement this with jquery very quickly with a small
> amount of code.
>
> When the form is submitted it is sent to the server with all of the
> data correctly passed. However, if I do a refresh, the dynamic fields
> go away, but the static fields still have data in them so I assuming
> that the dynamic data is still there.
>
> How can I verify this? When I show source, it only shows the original
> code; same even before the form is submitted. Is there a way to stop a
> refresh? This application may have 10 added fields or 300 added
> fields, and if the user does a refresh for some reason he'll want to
> see every thing that has been input so far.
>
> my code:
> $(document).ready(function() {
>     $("#divBoxes input:last").bind("change", appendBoxField);
>     $("#divBags input:last").bind("change", appendBagField);});
>
> function appendBoxField() {
>     var len = $("#divBoxes input").length + 1;
>     //alert(len);
>     $("#divBoxes").append('<input type="text"
> name="_UPS_Shipping_Label_' + len + '" />')
>     $(this).unbind("change", appendBoxField);
>     $("#divBoxes input:last").bind("change", appendBoxField).focus();}
>
> function appendBagField() {
>     var len = $("#divBags input").length + 1;
>     //alert(len);
>     $("#divBags").append('<input type="text" name="_photo_bag_ID_' +
> len + '" />')
>     $(this).unbind("change", appendBagField);
>     $("#divBags input:last").bind("change", appendBagField).focus();
>
> }
>
> Thanks,
>
> Terry

Reply via email to