/    Sign up×
Community /Pin to ProfileBookmark

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

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@hyperionXSFeb 23.2012 — HTML code
[code=html]
<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>
[/code]

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);
})
})
[/CODE]


  • 1. Fields you want to cache will have class="cookie" and MUST HAVE a distinct [B]name[/B] attribute

  • 2. Input and textarea elements are accepted

  • 3. I used jQuery and cookie functions (setCookie, getCookie, deleteCookie)

    from http://jquery-howto.blogspot.com/2010/09/jquery-cookies-getsetdelete-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.
  • ×

    Success!

    Help @sagheer_rajper spread the word by sharing this article on Twitter...

    Tweet This
    Sign in
    Forgot password?
    Sign in with TwitchSign in with GithubCreate Account
    about: ({
    version: 0.1.9 BETA 5.8,
    whats_new: community page,
    up_next: more Davinci•003 tasks,
    coming_soon: events calendar,
    social: @webDeveloperHQ
    });

    legal: ({
    terms: of use,
    privacy: policy
    });
    changelog: (
    version: 0.1.9,
    notes: added community page

    version: 0.1.8,
    notes: added Davinci•003

    version: 0.1.7,
    notes: upvote answers to bounties

    version: 0.1.6,
    notes: article editor refresh
    )...
    recent_tips: (
    tipper: @AriseFacilitySolutions09,
    tipped: article
    amount: 1000 SATS,

    tipper: @Yussuf4331,
    tipped: article
    amount: 1000 SATS,

    tipper: @darkwebsites540,
    tipped: article
    amount: 10 SATS,
    )...