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 8047623
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T06:09:47+00:00 2026-06-05T06:09:47+00:00

HTML: <div id=fields> <input type=text name=someField /> <!– NOTE: There are some more fields

  • 0

HTML:

<div id="fields">
    <input type="text" name="someField" />
    <!-- NOTE: There are some more fields here -->
</div>
<!-- NOTE: There are some more fields here -->

First JS File:

jQuery(document).ready(function($) {
    alert($('#fields input[type="text"]').val());
});

Second JS File:

jQuery(document).ready(function($) {
    $('#fields input[type="text"]').val('someValue');
});

Notes:

  1. The JS files are located within the head tag.
  2. I am forced to set the input value in the Second JS File.
  3. It works on Firefox, Opera, Chrome, Safari.
  4. IE7 and IE8 returns an empty value.

Any help is appreciated! Thank you!

  • 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-06-05T06:09:48+00:00Added an answer on June 5, 2026 at 6:09 am

    Instead of assuming that the value will have been set in your first “ready” handler, make it handle a custom event, and then trigger that event from the second file.

    First file:

    jQuery(function($) {
    
       $('#fields input[type="text"]').on('value-ready', function() {
          alert(this.value);
       });
    
    });
    

    Second file:

    jQuery(function($) {
      $('#fields input[type="text"]').val("whatever").trigger('value-ready');
    });
    

    wait a sec … this has the same problem 🙂 hold on and I’ll fix it … and stop upvoting me until I do 🙂

    OK assuming I’m right, that the issue is a dependency on the order of evaluation of “ready” handlers (and that’s essentially a “code smell” guess; there might be some other problem), the change I made won’t really help. If the second block runs first, then the event handler will not have been set up!

    I think that the only real way to impose an ordering is to either set up some kind of “promise” system, or else simply use a marker on the element, as well as a handler. That way, the code in the first block can check to see whether the value assignment has already happened. It’s a little clunky but at least it’s explicit:

    jQuery(function($) {
      var input = $('#fields input[type="text"]');
      if (input.data('value-ready'))
        alert("value already set: " + input.val());
      else
        input.on('value-ready', function() {
          alert("value is now set: " + input.val());
        });
    });
    

    and then in the second file:

    jQuery(function($) {
      $('#fields input[type="text"]').val("whatever")
        .data("value-ready", true)
        .trigger("value-ready");
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

here is link to an example: http://techchorus.net/demos/jquery/hiding-input-elements-in-a-div.html It actally disables few elements on click
So I have the following html: <div id=divForComponents> <input type=button value=+ onclick=addFilter('divForComponents')/> </div> And
$('#submit').click(function () { //Get the data from all the fields var name = $('input[name=name]');
I have a form with two input fields, one text and one send button.
My view: <div class=editor-label> @Html.LabelFor(model => model.UserList) </div> <div class=editor-field> @Html.ListBoxFor(model => model.SelectedUsers, new
I have an HTML div section with an empty table: <div id=report_result class=container> <table
I am trying to generate an html div in asp.net. Since a div is
What is the best way to set the transparency of a HTML DIV element
I have created a simple layout using the HTML div tag. I would like
how can i convert xpath like /html/body/div[3]/ul/li[1]/a[5] html > body > div[3] > ul

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.