I have used the following code to upload a file and display its contents in a text area however when i click upload file, it not only uploads the file and shows the contents but it also resets all other elements on the page to the default losing any values entered or any radio buttons set.
Is there a way to stop the upload form refreshing the entire page and setting all other elements back to the defaults?
you said 'on page load you will check to see if the cookie exists' Where would i put the code to check if the cookie exists? I dont know where in the code it re loads the page.
you said 'on page load you will check to see if the cookie exists' Where would i put the code to check if the cookie exists? I dont know where in the code it re loads the page.
This is all client side behaviour.
HTML + Javascript.
Cookie scripts are a dime a dozen.
Previously i gave you the html+js code that runs a js script on a page load.
Below is a rough js cookie code block. Im not trying to muck you around im just honestly restrained by two things.
1. I cannot be bothered writting the entire code for you
2. You wont learn much if i did anyway.
So im trying to stear you in the right direction and obviously failing miserably.
HTML Code:
<script type="text/javascript">
function checkcookie(){
someformdata = getCookie('someformdata');
if (someformdata != null && someformdata != ""){
//cookie exists now use the cookie data to load forms.
document.forms.formname.inputname.value = someformdata;
}
}
function getCookie(c_name)
{
if (document.cookie.length>0)
{
c_start=document.cookie.indexOf(c_name + "=");
if (c_start!=-1)
{
c_start=c_start + c_name.length+1;
c_end=document.cookie.indexOf(";",c_start);
if (c_end==-1) c_end=document.cookie.length;
return unescape(document.cookie.substring(c_start,c_end));
}
}
return "";
}
</script>
Bookmarks