www.webdeveloper.com
Results 1 to 2 of 2

Thread: Cache / cookies or script ? Help?

Hybrid View

  1. #1
    Join Date
    Feb 2012
    Posts
    1

    Cache / cookies or script ? Help?

    Dear Expert,

    I have the website where the html web Forms are exist....... so i just want to once people fill the form . the next time the fields automatically filled out. because fields are same to all web forms.

    Please give me the script or any suggestion

    Thanks


    Sagheer

  2. #2
    Join Date
    Feb 2012
    Posts
    218
    HTML code
    HTML Code:
    <input type="text" name="name" class="cookie" value="" />
    <input type="text" name="password" class="cookie" value="" />
    <input type="text" name="email" class="cookie" value="" />
    <input type="text" name="message" value="" />
    <textarea name="address" class="cookie"></textarea>
    JS Code
    Code:
    $(function(){
    	var prefix = 'cook';
    	
    	$('.cookie')
    	.each(function(){
    		if(!$(this).val()){
    			$(this).val(getCookie(prefix+$(this).attr('name')))
    		}
    	})
    	.change(function(){
    		if($(this).val()){
    			setCookie(prefix+$(this).attr('name'),$(this).val(),365);
    		}else{
    			deleteCookie(prefix+$(this).attr('name'));
    		}
    		// alert(document.cookie);
    	})
    })
    1. Fields you want to cache will have class="cookie" and MUST HAVE a distinct name attribute
    2. Input and textarea elements are accepted
    3. I used jQuery and cookie functions (setCookie, getCookie, deleteCookie)
    from http://jquery-howto.blogspot.com/201...te-plugin.html
    4. Use any value for prefix. It's just a precaution to not overwrite other useful cookies.
    5. As you can see, input name="message" does not have class="cookie". Value for this field will not be cached.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles