Now, if you look at the source of that page and Ctrl + F for function EpochToHuman1(), you'll find two instances of this function and for a few other functions too with exactly same code (two instances of the whole code actually starting from this function declaration).
On the frontend, there are two rows with some data, each row and its content is generated by one instance of that code. The complete second instance of the code is dynamically generated that outputs the second row. So basically this complete code is in a template that will always loop.
You'll notice that the correct values (Unix timestamp values) from the database are there in the code in their respective order within the function and is stored in the variables.
The problem I'm having is that the second row's data is being displayed in the first row and the first row data is never displayed (although its there as I see in the code).
I understand the code is not very optimized but that is the only way I could do this. So any help is really appreciated in order to resolve this problem, a dirty trick that does the job will do as well.
Also please note that I'm unable to alter the second instance of the complete code as it is generated dynamically at the server side, so changing function/variable names (if required) will not be possible unless we change it at the client side I guess.
Thanks for your reply! Like I had said earlier, there's not really a way I can eliminate the second copy of the duplicated script as its generated out of an uncontrolled loop (thats how the system is). And doing so would not solve the problem either. The loops must happen.
I have tried fiddling around with a copy of that page locally, and it seems that the similar function names is not really a problem but its the display variable name (result1, result2, etc..) being similar in both the instances that is blocking the values to display for an older entry.
If I change them to being unique somehow, it starts displaying the value. For example, if you look at the function EpochToHuman1(), it is using the below code to capture the value from the element ID "result1".
The above does the job fine, but for the second instance of the code, the result1 creates the block as it already has a value and overrides with the last one.
Now, I think dynamically changing all instances of resultx to being unique and having them inserted in the above two places throughout the loops should most likely resolve the problem. What do you think?
So the original code currently has result1, result2 etc.. in all functions for getElementById and they are being displayed as is. Need to figure out a way to dynamically replace the resultx thing with automatically incremental resultx's in the above two lines of code.
Or is there a way to simply clear out everything (meaning the executing functions) EXCEPT leaving the values on display (i.e. save them in memory), and execute the next duplicate instance of code again while going forward. Can we put a "Stop executing but keep displaying" kinda thing right after the first instance ends?
...
Also please note that I'm unable to alter the second instance of the complete code as it is generated dynamically at the server side, so changing function/variable names (if required) will not be possible unless we change it at the client side I guess.
Thanks
So who is generating the duplicated code on the server side?
Why do they (or you) generate it twice? For what purpose?
So who is generating the duplicated code on the server side?
Why do they (or you) generate it twice? For what purpose?
The page is built on an Adobe platform, and the code resides in a LIST template, that lists all the items in a web app. So for example, I have 100 entries in my database with email addresses, all 100 would list on a page. Each of the item would utilize that LIST template.
In my case, I have all that code in the LIST template, so it is being outputted as many times as I have entries in that web app. On my page, each data row you see (after the header row) is the result of the code I have in the LIST template. I have 2 items currently for the web app, hence 2 rows.
As the platform does not allow server side coding, much of the stuff needs to be done client side. I have Unix timestamps in the web app fields currently, that I am modifying to be readable on frontend via JavaScript, hence so much code.
1. You have a server that is generating code from a list you submit.
2. But you cannot change the server-side code nor the fact that it duplicates code depending upon your list.
3. Since javascript is a client-side language, I do not see anyway around this.
It cannot change the server-side display information being sent.
Sorry, I'm not sure I can be of much help!
Maybe some other forum members have some alternative suggestions.
Bookmarks