![]() |
![]() |
![]() |
||||
Welcome to the GoFuckYourself.com - Adult Webmaster Forum forums. You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today! If you have any problems with the registration process or your account login, please contact us. |
![]() ![]() |
|
Discuss what's fucking going on, and which programs are best and worst. One-time "program" announcements from "established" webmasters are allowed. |
|
Thread Tools |
![]() |
#1 |
Too lazy to set a custom title
Industry Role:
Join Date: Aug 2002
Posts: 55,364
|
how to clear an input after submit in jquery?
here is the code i have (it does live search)
Code:
jQuery(document).ready(function ($) { var contentCache, searched = false; jQuery('#searchform').submit(function () { var s = jQuery(this).find('#s').val(); if (s.length == 0) { return; } var submit = $('#searchsubmit'); submit.attr('disabled', false); var url = jQuery(this).attr('action') + '?s=' + encodeURIComponent(s) + '&action=search_ajax' jQuery.ajax({ url: url, type: 'get', dataType: 'html', beforeSend: function () { submit.attr('disabled', true).fadeTo('slow', 0.5); document.body.style.cursor = 'wait'; var load = '<div id="content" role="main"><h1 class="page-title">Searching...</h1></div>'; jQuery('#container').empty().html(load); }, success: function (data) { submit.attr('disabled', false).fadeTo('slow', 1); document.body.style.cursor = 'auto'; jQuery('#container').empty().html(data); jQuery('#ajaxback').click(function () { jQuery('#container').empty().html(contentCache); }); } }); return false; }); var timer, currentKey; jQuery('#s').keyup(function () { clearTimeout(timer); timer = setTimeout(function () { var sInput = jQuery('#s'); var s = sInput.val(); if (s.length == 0) { if (searched) { jQuery('#container').empty().html(contentCache); sInput.focus(); //jQuery('#search-form span.processing').remove(); searched = false; } currentKey = s; } else { if (s != currentKey) { if (!searched) { contentCache = jQuery('#container')[0].innerHTML; searched = true; } currentKey = s; if (s != ' ') { jQuery('#searchform').submit(); } } } }, 800); }); });
__________________
Since 1999: 69 Adult Industry awards for Best Hosting Company and professional excellence. ![]() WP Stuff |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#2 |
Totally Borked
Industry Role:
Join Date: Feb 2005
Posts: 6,284
|
huh? Why do you want to clear the form? Why not have it clear the next time the cursor is clicked on the text field? That way the user still sees their search term in the text form?
Anyway, a simple form reset should suffice no? onsubmit="this.submit(); this.reset();"
__________________
![]() For coding work - hit me up on andy // borkedcoder // com (consider figuring out the email as test #1) All models are wrong, but some are useful. George E.P. Box. p202 |
![]() |
![]() ![]() ![]() ![]() ![]() |