checkbox operation in jsp - javascript

I am trying this one to solve since last night but could not hence asking for help.
There are two pages, such as name.jsp and roll.jsp. In name.jsp there are two input text boxes and one checkbox.I entered data in two text boxes and i checked the check box , when i checked the check box i am going to roll.jsp and in roll.jsp 2 text boxes are present.
When I reached roll.jsp by clicking checkbox, I kept the link(name.jsp) on roll.jsp page and when i am clicking name.jsp I am not able to see my previously entered data on two textboxes. How can i achieve this? I am going to roll.jsp through a checkbox and i want to see all my previously entered data on name.jsp when i am clicking name.jsp hyperlink which is present in roll.jsp. How to achieve it? Two different forms are in these two pages.
Any help is much appreciated

When you have navigated away from page, all its input data will be lost. To remain it, you have to carry the data over either by request or through saving the data in a database/localstorage.
OR
You can try to use an iframe/SPA kind of behaviour. Where roll.jsp is loaded within the name.jsp either by iframe or using AJAX to bring in the content. That way you would not have navigated away from the page and thus the input data can still be used.

On event of click, if that checkbox is checked, make a call for roll.jsp, which will submit the value of current 2 textbox as well as it will show in roll.jsp.
For showing the previously entered values, accept using request.getParameter(string) and print that in roll.jsp.
Whatever the response will come from roll.jsp, print that is one div.
Hope your problem is solved.

Related

How to set cascade select2 value onClick

I have three select2 lists next to each other, first independent, second dependent on first, third dependent on second (cascading lists), that works as expected when I normally populate them by selecting some options. I have created a dynamic action that fills these items with values that I calculate when I click a button, but after the click, only the first select2 have selected value. The second and third value remains empty. When I check the session, all items have value in them. It appears that when I click the button that for a millisecond list are filled but after that values disappear. So my question is, how do I transfer values from server-side to client-side. I tried to refresh items, I have played with jQuery without success, also I have tried to separate dynamic action to set values separately but nothing worked. Values populate correctly so that is not the problem. Please help
Thank you in advance for your answer.
Is lazy loading checked for the select2 that are subject to this behaviour (Item -> Setting -> Lazy loading)? If so try unchecking it

displaying the value of a checkbox in a div with javascript

In my application I will eventually want to dynamically assign values to certain checkbox values but where I am at currently is this.
When the page first loads, a set of checkboxes load and when any of these are checked, a corresponding div is revealed nearby. In THAT div there is an additional checkbox that drops down a section of text that should match what the value of the original checkbox value is.
I have the click a box, reveal a box, click a box, reveal the text part working correctly but what it displays is hardcoded and I'm trying to figure out how to pass the values of the checkboxes around to tie everything together dynamically. Thank you for your assistance on this.

Show text box when checkbox clicked and keep showing after page reload

I have written a JavaScript function that shows a text input field when a checkbox is clicked. The essence of the function is basically to change the text box display property from "none", to "block" on checkbox click. This works fine, and thus when I check the box I see the text field, and when I uncheck the box, the text box hides.
Now, I am trying to figure out how to keep the text box showing after the page is refreshed. This is where I am stuck.
Any suggestions? Thanks!
Please let me know if I need to clarify anything!
Best way is to store your state in a cookie and read it after load to get back to the same state : Set cookie and get cookie with JavaScript

Changing database values in an HTML table

I have written a control panel for managing devices, however as we have imported hundreds of them, there are a lot of values that need to be manually set. I have an overview page that shows the most import information and I am looking at some way to allow the end-user to change those values by clicking them.
Right now they are just text in TD cells pulled from the Database. Would it be possible to do something like double clicking the cell changes it to a drop-down box of options and then when deselected it automatically saves it to the database?
I have been searching Google and Stack Overflow but I am not even sure what to search for to get an idea of how to accomplish this.
To do this you must (short version):
Handle click event on your value from table
Change(hide text and display input) text for input with setted value
Handle blur event on your input
If some changes have been made, send Request (by AJAX) to your php actions which save value in database. Or do nothing if there were no changes.
Change(hide input and display text ) input to text

How to improve the onChange attribute to effect the changes after browser refresh?

I have a dynamic form which depending on the value in a pull down selection field will either show or hide a form fieldset.
e.g. Do you wish to get a quote just now? [YES/NO]
This works fine the way it is at the moment however there is a limitation when the user refreshes the form and the value is still intact however the changes that should have made an effect on the document are not shown. i.e. it is reset to its original state
The only way to remedy this is to redo the selection in that form field i.e. (reclick Yes/No).
Is there anyway I can workaround this problem? Perhaps a seperate javascript that checks the value of that field?
How would you tackle it?
Thanks
A refresh reinitialises the page so will reset everything that the browser doesn't remember for you. The only way would be to store the value in a session/cookie and read it each time the page is loaded to check if the fieldset should be shown on hidden.

Categories