Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6672597
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T03:31:37+00:00 2026-05-26T03:31:37+00:00

I’m trying to use jquery to set some default text in a form input.

  • 0

I’m trying to use jquery to set some default text in a form input. The text will be dynamic and so I can’t just set this in the html. I want the jquery to wait for the form to load.

The delay function sets the text, but doesn’t delay at all. It’s instant.

Nothing in the load function seems to execute.

HTML code:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Testinput</title>
<script type="text/javascript" src="jquery.min.js"></script>
<script type="text/javascript" src="testinput.js"></script>
</head>

<body>
<form>
  <input size="20" name="thing" />
  <input type="image" src="" name="submit" value="go" />
</form>

</body>
</html>

JQuery code:

$(document).ready(function(){

var $input = $('input[name="thing"]');
$input.val("");

var query = "orange";

//$input.delay(10000).val(query); // No delay!

$input.load(function(){ 
// Nothing happens!!
alert("form loaded");
$input.val(query);
});

});

Tried both jquery-1.6.4.min.js and jquery-1.4.min.js to no avail.


Edit:
I can’t respond to replies, javascript on stack overflow doesn’t seem to be working correctly for me. I get “Stack Overflow requires external JavaScript from another domain, which is blocked or failed to load”.

I’ve gotten the delay function working using Clive’s answer, but is there a way to make jquery wait for a form to have loaded first before running code?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T03:31:38+00:00Added an answer on May 26, 2026 at 3:31 am

    delay() relates to queues, not arbitrary functions so you need to use setTimeout() instead:

    window.setTimeout(function () {
      var $input = $('input[name="thing"]');
      var query = 'orange';
      $input.val(query);
    }, 10000);
    

    Also load() is a function to:

    Load data from the server and place the returned HTML into the matched element.

    It won’t work for what you’re trying to do

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For some reason, after submitting a string like this Jack’s Spindle from a text
I am trying to understand how to use SyndicationItem to display feed which is
I have just tried to save a simple *.rtf file with some websites and
I have a jquery bug and I've been looking for hours now, I can't
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have a text area in my form which accepts all possible characters from
Does anyone know how can I replace this 2 symbol below from the string
I'm trying to use string.replace('’','') to replace the dreaded weird single-quote character: ’ (aka
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have some data like this: 1 2 3 4 5 9 2 6

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.