please help I am running out of time Query Strings and Storing Persistent Inform
ID: 3746748 • Letter: P
Question
please help I am running out of time
Query Strings and Storing Persistent Information
Overview
As Web forms get longer, we very commonly see them split across multiple pages to collect all of the necessary information. There are different reasons for this. A long form can be daunting for users and a large/long form can be difficult for users to fill out on a mobile device. These forms need to be designed so that the data entered by the user on the forms on each page will be submitted to the Web server simultaneously. This makes more sense as they are part of the same data set. The problem with stateless pages is that if the user moves from one page to the next, the data entered is lost. To bypass this issue, you will need to use query strings, hidden input fields, and cookies.
In this assignment you will use the previously created registration.html file to send information to a second page named confirm.html. You will write a script on that page that will save the information from the form to a cookie and then display it on a same page. If the user goes back to this confirm.html page, the page should display the user form data from the registration entry that was last entered.
Tips:
It will help to output the array into the browser console so that you can verify that the string is being correctly parsed. Details on the browser console can be found in the Resources.
To skip having to enter data into the form each time to test, it may help to create a JavaScript function that automatically fills in the fields for you and comment it out when completed.
Directions
Read the Overview.
Modify the "registration.html" page created in the prior assessment to send a query (that has all input field information from that form) to a second page. When the user presses submit, all of the input fields from the registration.html form will be saved into a cookie. The user should then be forwarded to a second page (confirm.html (created by you)) that will read the cookie information and display it in a name/value pair using JavaScript.
Make sure to do the following:
Create and integrate a script on the registration.html page passes all of the input fields from the form when the submit button is pressed.
Create a confirm.html page will read in the input from the query string data from the registration.html page and store them into variables first.
Write a script that runs in response to the submit event, that saves the input from the registration.html page to a series of cookies to store each input, and opens a second page called confirm.html that reads and displays information from all the fields.
Once completed, view your pages in each of your two selected Web browsers to see if the content renders appropriately and consistently within each. Next, verify that your code is error-free using the appropriate browser-specific development tool found in the Resources. Take a screen capture of each of your validation results and save it for submission.
Submission Requirements
Upload your Web site files to your Web host.
Submit your work in the courseroom using a single Zip file containing the following:
Your entire Web site and all associated files.
A Word document with:
The url to your Web site so faculty can view your site on a live host.
A screen capture of each of your two validations that you completed using the developer tools found in the Resources.
Resources
Explanation / Answer
As the content of the registration page is not provided in the page. So, I will try to just tell you the method to save data to cookie and extract it back to a file.
Cookie is just a small text file stored in the local system so that is stored in the local filesystem.
I will give you the procedure to process cookies.
In Registration.html page, u can add this javascript.
document.cookie = "username = abc, userid = 1, user_details: abc_university; path = /"
//path = / means the current webpage.
You can also create multiple cookies to faciliate the feature and document .cookie will not overwrite them . they will store different cookies for each and every entry.
Now, for retrieving the cookie information, we do.
in Confirm.html
function getinfo(name) {
var n = name + "=";
var Cookie = decodeURIComponent(document.cookie);
var c = Cookie.split(';');
for(var i = 0; i <c.length; i++) {
var co = c[i];
while (co.charAt(0) == ' ') {
co = co.substring(1);
}
if (co.indexOf(n) == 0) {
return co.substring(n.length, co.length);
}
}
return "";
}
The above function decodes the cookie and Split() function splits the input in information and path and (maybe expiry if used).
Then the the information is retrieved and passed back to the html file for display.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.