I have a php "add classified" page where users may fill in details in several drop-lists.
At the bottom开发者_JS百科, I have a picture upload tool, which requires the page to submit to itself, and then preview that image. Problem is, whenever this is done the drop lists values are resetted, so the users have to re-select everything.
I have asked this Q before, but the method I went with doesn't work I have noticed now... here is the Q: 'Remember' form drop list value when submitting to SELF?
I have managed to solve this, as mentioned above, by using javascript with PHP to "grab" the value of the chosen option, and then use the value which has an ID with the same name exactly, and add a selected tag to it. See below: (this js is at the bottom of the page)
var areaOption = byId("<?php echo @$_POST['annonsera_area'];?>") || "Välj Län";
areaOption.selected=true;
The problem here is that whenever an element has the same id as another one, it wont work. And I have to use same ID:s, because alot of the options are "years" which the users may select as "make year" of their "vehicles"...
Anyways, is there any other way to solve this?
Thanks
Have you considered using an AJAX-style file upload script? For example:
http://www.uploadify.com/
This would allow your users to upload an image to the page without having to submit the entire form or refresh the page.
Technically you shouldn't have identical IDs. Try to rethink how you are doing it, but otherwise, you could use AJAX (assuming that you are happy to only support people with javascript enabled).
精彩评论